30 Jul 2010

Basic .htaccess Modifications

This is a useful .htaccess for a basic CakePhp website. It enables
compression, normalises URLs by removing 'www' and then moves on to the
standard CakePhp redirection:
# compress all text & html:
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css 
text/javascript
<IfModule mod_rewrite.c>
RewriteEngine on
# Convert all http://www.example.com style URLs to http://example.com
RewriteCond %{HTTP_HOST} ^www\.(.+)$
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>
In certain situations - in this case our CMS - this substitution might 
be useful:
#RewriteRule    ^$ app/webroot/    [L]
RewriteRule    ^$ my-anchor-page    [L]

No comments:

Post a Comment