Tag Archives: mod_rewrite

mod_rewrite to force www redirect index.php to domain

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]

mod_rewrite to move one domain to another

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 [...]

Mod_Rewrite Canonicalization Avoids Duplicate Content

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? [...]