I’m having a problem where 301 redirects are creating funny URLs with /?/ in them.
The URLs are showing the correct page, but are a problem because they considered different URLs by google, and so are creating a lot of pages with duplicate content.
For example, the line:
Redirect 301 /hygiene/contact.html http://www.cmpsolutions.net/contact
Should redirect http://www.cmpsolutions.net/hygiene/contact.html to http://www.cmpsolutions.net/contact, but instead I’m getting http://www.cmpsolutions.net/contact/?/hygiene/contact.html/
I can’t figure out why the original URL segment is being attached to the end after an added “/?/”
Can someone please help.
I’m using the following .htaccess rules (not including individual 301 redirects):
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /
# Add Trailing Slashes to URLs
# ------------------------------
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+[^/])$ /$1/ [R=301,L]
# Redirect all traffic to www
# ------------------------------
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ <a href="http://www.%{http_host}/$1">http://www.%{http_host}/$1</a> [R=301,L]
# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]
# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>One thing to note, which is different than some servers: The last line:
RewriteRule ^(.*)$ /index.php?/$1 [L] - needs the “index.php?” instead of just “index.php” to work properly on my MediaTemple DV server.
Does it have something to do with the order in which these rules are executed? I’ve a tried a few different orders and can’t seem to solve it.