Page is a not externally linkable
TheMadScientist - 1:37 pm on Jan 11, 2013 (gmt 0)
Wow, it looks like the code's been Way over complicated for a simple http https redirect difference ... I would think all we would need are 2 rules, one with an extra condition to check the port:
# Redirect All Non-Port 443 Requests Containing index.htm
# Rule is first using a negative match for efficiency, assuming http is most used
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.htm[^\ ]*\ HTTP/
RewriteRule ^(([^/]+/)*)index\.htm$ http://www.example.com/$1? [R=301,L]
# Redirect Requests Containing index.htm on Port 443 to https URLs
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.htm[^\ ]*\ HTTP/
RewriteRule ^(([^/]+/)*)index\.htm$ https://www.example.com/$1? [R=301,L]
I'm fairly certain only specific underlying operating systems allow for the use of shorthand with mod_rewrite (EG \s), which is why there's difficulty finding anyone who posts mod_rewrite expressions online using any of them, even if we do regularly use them in other coding ... There's nothing quite like changing hosts and having an .htaccess file stop working, because the patterns used for matching in mod_rewrite are 'not accepted' by the new server ... It's not some fun, believe me lol