Forum Moderators: Robert Charlton & goodroi
AddType application/x-httpd-php5 .htm .html
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.mysite.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ https://www.mysite.com/$1 [R=301,L]
# Redirect non-canonical to www
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} !^(www\.mysite.com\.com)?$
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} !^(www\.mysite.com\.com)?$
RewriteRule (.*) https://www.mysite.com/$1 [R=301,L]
#No permitir direcciones como mysite.com/pagina1.htm/maps/ etc
RewriteRule ^((?:[^./]+/)*[^./]+\.(?:html?|php))/ http://www.mysite.com/$1 [R=301,L]
[edited by: Robert_Charlton at 4:39 pm (utc) on Mar 25, 2013]
[edit reason] removed specifics, per Charter [/edit]
Does this problem occur only with http pages? Otherwise you'd need a pairing of rules, as with all the others.