Forum Moderators: phranque
/folder/index.html
and
/folder/
be considered as duplicated content.
Anyhow, since I like the "/" mode, I have a question about the code below:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ http://www.example.com/$1 [R=301,L]
The * prior the index, would that also include a page like /123index.html?
Thanks
However, would you really want to redirect that to www.example.com/123 and without a trailing slash?
The code would also redirect /folder/index.html to www.example.com/folder/
There's also a much more efficient way to capture folder depths for redirecting. It's been posted dozens of times over the last year or two.
Let's just put it the other way:
I don't want anything except "bare real" index.html to be redirected to it's folder, aka the same page.
The example I provided is from this forum, and the ".*" has confused me as it looked like more than just "index.html" could be picked, so I wondered about it.
My goal is to resolve an issue of "index.html" pages only, period.
I'll check the previous posts again, and try to figure out the code that looks "index" only to me.
Thanks
I just found that on one of the shared hostings I use, if I type a full URL with a typo like "5index.html" or "tindex.html", the server "nicely" redirects to index.html
I exclude the code I asked about, and same thing happens again. I check the site that has never had this code, same again.
I check one of other sites with different provider, I get the expected 404.
Is it common that shared hosting providers correct what they think is a mistake? I assume if I had the page "tindex.html" that it would load - I guess, haven't tried.
Anyway, now after I tested this on a different server (that does not guess), it worked as expected, so thank you very much!
I guess my original code would work too, but as one said, listen to Jim! ;)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.example.com/$1 [R=301,L]
Jim