Simple question about htaccess rule: how can I redirect all queries like "domain.com/index.html" to "domain.com" so the index.html wouldn't be seen on address bar in web browser (or in google, etc)?
Does it automatically go to /index.html when just going to the site by typing in domain.com? If so, this will cause a loop and won't work
No it doesn't, so there's no fear of a loop Anyway, I've find out how to achieve it just after wrote this post, so: RewriteCond %{the_request} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/ RewriteRule ^(.*)index\.html$ http://domain\.com/$1 [l,r=301] Code (markup):
I was having the same problem. I wanted every case of /index.[html|htm|php] to always redirect to just the [/] directory folder that holds the index file, whatever it may be. I accomplished this task by changing around Sorror's suggested code a bit. This works great for me on my server: RewriteEngine on RewriteCond %{the_request} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/ RewriteRule ^(.*)index\.html$ http://www\.mydomain\.com/$1 [R=301,L] RewriteCond %{the_request} ^[A-Z]{3,9}\ /.*index\.htm\ HTTP/ RewriteRule ^(.*)index\.htm$ http://www\.mydomain\.com/$1 [R=301,L] RewriteCond %{the_request} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/ RewriteRule ^(.*)index\.php$ http://www\.mydomain\.com/$1 [R=301,L] Code (markup):