Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- 301 redirect best practice


kellyman - 8:46 pm on Sep 8, 2012 (gmt 0)


OK

Kind of confused with the terminology but kind of have the idea,

so if i wanted the second part of this htaccess added to the new site which i will do Monday, is this correct allowing for already redirected pages


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]

# 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]


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