/ Published in: Apache

Disable directory indexing, custom error messages, PHP processing in other files, mod_rewrite, file GZIP and cache expiration times.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
## Disable directory browsing Options All -Indexes ## Custom error messages (forbidden, notfound, servererror) ErrorDocument 403 /error.php?n=403 ErrorDocument 404 /error.php?n=404 ErrorDocument 500 /error.php?n=500 ## If you need to process CSS files as PHP ## AddType application/x-httpd-php .css ## Compress all text, html, javascript and css: AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript application/javascript text/css ## Rewrite RewriteEngine on RewriteRule ^search/([a-zA-Z0-9]*)/(.*^&)$ ?q=$2&se=$1 [nc] RewriteRule ^info$ ?page=info [nc] RewriteRule ^type/([a-zA-Z0-9]*)$ ?t=$1 [nc] RewriteRule ^limit/([0-9]*)$ ?l=$1 [nc] RewriteRule ^go/([a-zA-Z0-9]*)$ ?go=$1 [nc] ## Cache Expiration times # 1 YEAR <FilesMatch "\.(ico|flv)$"> Header set Cache-Control "max-age=29030400, public" </FilesMatch> # 1 MONTH <FilesMatch "\.(jpg|jpeg|png|gif|swf)$"> Header set Cache-Control "max-age=2419200, public" </FilesMatch> # 1 WEEK <FilesMatch "\.(doc|xls|ppt|pdf)$"> Header set Cache-Control "max-age=604800, public" </FilesMatch> # 2 DAYS #<FilesMatch "\.(xml|txt|css|js)$"> #Header set Cache-Control "max-age=172800, proxy-revalidate" #</FilesMatch> # 1 MIN #<FilesMatch "\.(html|htm|php)$"> #Header set Cache-Control "max-age=60, private, proxy-revalidate" #</FilesMatch>
Comments
