Från Googlehemsida
I .htaccess kan man göra massor av trix för att sidan ska prestera bättre. Denna sida listar några av dem mest användbara. Filen .htaccess läggs i rooten av dem mappar den ska styra över.
Innehåll |
[redigera] Gzip
# compress all text, html and images: AddOutputFilterByType DEFLATE text/html text/plain text/xml image/jpeg image/png image/gif
[redigera] Redirect till www
#Redirect from non-www to www RewriteCond %{HTTP_HOST} ^exempel\.se [NC] RewriteRule (.*) http://www.exempel.se/$1 [R=301,L]
[redigera] Redirect till non-www
#Redirect from www to non-www RewriteCond %{HTTP_HOST} ^www\.exempel\.se [NC] RewriteRule (.*) http://exempel.se/$1 [R=301,L]
[redigera] Lägg till expires
#Add expire headers <IfModule mod_expires.c> ExpiresActive on #images ExpiresByType image/jpg "access plus 1 week" ExpiresByType image/jpeg "access plus 1 week" ExpiresByType image/gif "access plus 1 week" ExpiresByType image/png "access plus 1 week" ExpiresByType application/x-shockwave-flash "access plus 1 week" #pages and js ExpiresByType text/html "access plus 1 day" ExpiresByType text/js "access plus 1 day" #others ExpiresDefault "access plus 2 days" </IfModule>
[redigera] Hidra att folk snokar i .svn-mappar
#disable browsing in .svn <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} /\.svn/ RewriteRule . - [F] </IfModule>
[redigera] Byt namn på en fil
# Rewrite robots.txt to robots.php: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule robots.txt robots.php [L]
[redigera] Speciella felsidor
# Customized server error messages: ErrorDocument 404 /error404.php ErrorDocument 403 /error403.php