View Full Version : .htaccess duplicate content redirect problem

02-13-2011, 06:04 PM

Google is now indexing pages on my site causing duplicate content issues because the .htaccess is not redirecting properly.

Google caches the following Urls


Options +FollowSymlinks
RewriteEngine on

# Externally redirect direct client requests for script filepaths back to "friendly" extensionless URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]*/)*[^.]+\.php([?#][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]*/)*[^.]+)\.php$ /$1/ [R=301,L]

# Externally redirect to add missing trailing slashes to extensionless URL requests
RewriteCond $1 !\.[a-z]+[0-9]?$
RewriteRule ^(.*[^/])$ http://www.somesite.co.uk/$1/ [R=301,L]

# Externally redirect all non-canonical hostname requests to canonical hostname
RewriteCond %{HTTP_HOST} !^www\.somesite\.co\.uk$
RewriteRule ^(.*)$ http://www.somesite.co.uk/$1 [R=301,L]

# Internally rewrite all requests ending with slash to php scripts
RewriteRule ^(.*)/$ /$1.php [L]