0

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.

1 Answer 1

1

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]
Sign up to request clarification or add additional context in comments.

2 Comments

I'm probably wrong, but doesn't (.*) make [A-Z]{3,}\s unnecessary?
(.*) must be part of URI before index.php, we don't want to capture GET in %1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.