Forum Moderators: phranque
RewriteCond %{HTTP_HOST} ^example.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.net$
There should be no difference in a 301 redirect returned by PHP or by htaccess. A redirect is a redirect.
Things go wrong when a request results in an unwanted multiple step redriection chain. You should test a selection of canonical and non-canonical requests and look in detail at the Live HTTP Headers extension for Firefox for the results.
Redirecting old site page X to new site page Y should NOT pass through old site page Y or through new site page X on the way.
with this on the old server
RewriteEngine on
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
and this on the new server (thanks to g1smd) who supplied this for me
# 31 - Redirect index requests on new server
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index(\.(php|html?))?
RewriteRule ^(([^/]+/)*)index(\.(php|html?))?$ http://www.example.com/$1? [R=301,L]
# 32 - Redirect .php requests to extensionless URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*[^/.]+)\.php
RewriteRule ^(([^/]+/)*[^/.]+)\.php$ http://www.example.com/$1? [R=301,L]
# 33 - Redirect non-canonical requests to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
However because of the way my guy has called the PHP redirects I am convinced they are chaining somewhere.
?cat=<num> and ?id=<num> parameters were rewritten to a PHP script. The script looked up the new URL in an array and used the PHP HEADER directive to send a 301 redirect. RewriteCond. Without this condition, the internal rewritten path would be exposed back out on to the web as a new URL when non-www URLs are requested. internal redirects
Hi when i mean Internal redirects i have pages were the names changed a
so for instance http://www.example.com/oldpage needs redirecting to http://www.example.com/newpage
# 32 - Redirect .php requests to extensionless URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*[^/.]+)\.php
RewriteRule ^(([^/]+/)*[^/.]+)\.php$ http://www.example.com/$1? [R=301,L]
You explained it perfectly adequately. This should do it, on all the rules that interfere with form submission:
RewriteEngine on
# 2 Redirect Individual renamed pages
RewriteRule ^oldpage1$ http://www.example.com/test/newpage1? [R=301,L]
RewriteRule ^oldpage2$ http://www.example.com/test/newpage2? [R=301,L]
RewriteRule ^oldpage3$ http://www.example.com/test/newpage3? [R=301,L]
RewriteRule ^oldpage4$ http://www.example.com/test/newpage4? [R=301,L]
RewriteRule ^oldpage5$ http://www.example.com/test/newpage5? [R=301,L]
RewriteRule ^oldpage6$ http://www.example.com/test/newpage6? [R=301,L]
RewriteRule ^oldpage7$ http://www.example.com/test/newpage7? [R=301,L]
RewriteRule ^oldpage8$ http://www.example.com/test/newpage8? [R=301,L]
RewriteRule ^oldpage9$ http://www.example.com/test/newpage9? [R=301,L]
RewriteRule ^oldpage10$ http://www.example.com/test/newpage10? [R=301,L]
RewriteRule ^oldpage11$ http://www.example.com/test/newpage11? [R=301,L]
# 10 - ignore Page
RewriteCond %{REQUEST_URI} !^/run\.php
# 31 - Redirect index requests on new server
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index(\.(php|html?))?
RewriteRule ^(([^/]+/)*)index(\.(php|html?))?$ http://www.example.com/$1? [R=301,L]
# 32 - Redirect .php requests to extensionless URL
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*[^/.]+)\.php
RewriteRule ^(([^/]+/)*[^/.]+)\.php$ http://www.example.com/$1? [R=301,L]
# 33 - Redirect non-canonical requests to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]