I'm in the process of moving a site from one domain to another, so I'm setting up 301 redirects on the old domain. Everything goes well, except when the 301 redirect happens, "index.php" is inserted into the URL.

Here's the relevant code in my ".htaccess" file:

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]

    RewriteCond %{HTTP_HOST} ^www\.newdomain\.com [NC]
    RewriteRule ^(.*)$ http://newdomain.com/$1 [L,R=301]

    RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC]
    RewriteRule ^(.*)$ http://newdomain.com%{REQUEST_URI} [R=301,L]

FWIW, I've verified that "omitScriptNameInUrls" is set to "true" and my server does support PATH_INFO.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.