February 28, 2010 – 9:18 pm
Here is a quick mod_rewrite example that forces www and redirects index.php to / (this fixes two canonicalization issues at one time).
?View Code PHPRewriteEngine on
RewriteCond %{HTTP_HOST} !^www.site.com$
RewriteRule ^/(.*)$ http://www.site.com/$1 [R=301]
RewriteRule ^/index\.php$ http://www.site.com/ [R=301,L]
August 10, 2009 – 5:07 pm
There may come a day when you need to move one domain’s content to another. This can easily be done with a little mod rewrite trickery in apache.
Note the ^/ on the RewriteRule line, I have that because my server automatically adds the trailing slash, and if I don’t put this it will add [...]
Apache’s mod_rewrite has been the bane of many. I think it is mostly the use of regular expressions that is the bane of many instead, but you get the idea.
I want you to take a look at the following URLS:
domain.com
domain.com/
www.domain.com/
www.domain.com
domain.com/index.html
www.domain.com/index.html
Do they all look the same to you? Well they are not the same to [...]