Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- index.php redirect breaking 404 pages.


Sgt_Kickaxe - 5:59 am on Dec 9, 2012 (gmt 0)


To clarify, the following works for visitors but it creates a double 301 redirect for the RedirectMatch if www is not present or /index.php/ is present in the request url(on wordpress sites).

# redirected url
RedirectMatch Permanent ^/some-old-url$ http://www.example.com/the-new-url

# remove index.php from urls
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.php(/[^\ ]*)?\ HTTP/
RewriteRule ^index\.php(/(.*))?$ http://www.example.com/$1 [R=301,L]

# add www if it's missing
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

# wordpress basic
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


In spending the past hour searching the net I've found that this is a problem other wordpress sites have too and the owners may not even be aware of it. I haven't found a solution yet.

From: /index.php/some-old-url
To: /some-old-url <----- why is this 301 happening with the above?
To: /the-new-url


Thread source:: http://www.webmasterworld.com/apache/4520914.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com