Forum Moderators: phranque

Message Too Old, No Replies

order of domain rewrites

minimise redirects

         

santapaws

10:08 pm on Jan 11, 2016 (gmt 0)

10+ Year Member



Can anyone please tell me if this is the correct order for these domain rewrites? im not sure what should come first to minimise the number of redirects. I find it all confusing :)

#####http to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ [%{HTTP_HOST}%{REQUEST_URI}...] [L,R=301]
##### Resolve index.html to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]*/)*index\.html? [NC]
RewriteRule ^(([^/]*/)*)index\.html?$ [domain.com...] [R=301,L]
# remove multiple slashes anywhere in url
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . [domain.com%1...] [R=301,L]
# Redirect to remove multiple slashes before URL-path
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ //+([^\ ]*)
RewriteRule .* [domain.com...] [R=301,L]
##### Resolve canonical domains
RewriteCond %{HTTP_HOST} !^(www\.domain\.com)?$
RewriteRule ^(.*)$ [domain.com...] [R=301,L]

not2easy

1:04 am on Jan 12, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I can tell you this is not in optimal order. Some of these rewrites can be combined, and there was a recent discussion of this that might help with both understanding and proper order: [webmasterworld.com...]