Page is a not externally linkable
helenp - 9:33 am on Jan 15, 2013 (gmt 0)
Tried to mix G1Smd's code with TheMadScientists code to fit my needs but redirects index.htm on third level (mysite/file/file/index.htm) from http to https
Correct. That code redirects everything to http and www.
If you have part of a site using https, then you'll need another rule for that, redirecting to https.
To make it all work, both of the rules will need extra preceding conditions: one testing the requested port is ^443$ or !^443$ and the other testing the requested path and file that should be http or should be https.
I tried this:
# Redirect index.html and .htm to folder
RewriteRule !index\.html? - [S=2]
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ https://www.example.com/$1 [R=301,L]
# Redirect non-canonical to www
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) https://www.example.com/$1 [R=301,L]