To remove index.htmlor index.htmfrom URLs, I use the following in.htaccess
RewriteCond %{REQUEST_URI} /index\.html?$ [NC]
RewriteRule ^(.*)index\.html?$ "/$1" [NC,R=301,NE,L]
It works! (More on the checkboxes at the end of this question *)
Then, to add wwwin the urls, I use the following in my.htaccess
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ "http://www.mydomain.com/$1" [R=301,NE,L]
It works too!
The question here is how to avoid the double redirection created by the rules above in cases like the following:
- browsers request
http://mydomain.com/path/index.html - the server sends a header
301 to redirect the browser tohttp://mydomain.com/path/ - then browser requests
http://mydomain.com/path/ - the server sends a header
301 to redirect the browser tohttp://www.mydomain.com/path/
, , , , http://mydomain.com/path/index.html, , , . , Googlebot ( , , .)
!
* :
NC
, .. index.html/
index.htmNE
url
http://.../index.html?hello=ba%20be
http://.../index.html?hello=ba%2520beQSA
, ..
http://.../index.html?hello=babe
http://.../?hello=babe ( anubhava)