Reputation: 95
converted wordpress site into a static html using httrack. Now I want to remove index.html from my url, but anything I put in .htaccess doesn't work correctly.
example: (this is on my test server) I want to change page structure url from this: http: popartcode.space/megalsistemi.com2/o-nama/index.html to this: http: popartcode.space/megalsistemi.com2/o-nama/
This is what I tried, it messed up half of my links:
RewriteEngine On
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
Another try:
RewriteCond %{THE_REQUEST} \/index\.(php|html)\ HTTP [NC]
RewriteRule (.*)index\.(php|html)$ /$1 [R=301,L]
This changed my link from this:
http: popartcode.space/megalsistemi.com2/o-nama/index.html to this:
http: popartcode.space/o-nama/
which is not since, since i only need "index.html" removed.
Any help would be much appreciated. Thank you.
Upvotes: 0
Views: 4558
Reputation: 786091
You can use this rule:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.(php|html)\ HTTP [NC]
RewriteRule (^|/)index\.(php|html)$ /%1 [NC,R=301,L]
Upvotes: 1