D
D
Dpy3b2021-04-11 12:10:35
htaccess
Dpy3b, 2021-04-11 12:10:35

How to remove index.html from url?

Hello, there is a .htaccess file, its content is:

RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([^.]+)\.html\ HTTP
RewriteRule ^([^.]+ )\.html$ /$1 [R=301,L]
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (. *) /$1.html


RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://%{HTTP_HOST}/ [R=301, L]


Tails in the form of .html are removed, but /index still remains on the main page
How should the final .htaccess file look like so that index.html is also removed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dpy3b, 2021-04-11
@Dpy3b

RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[AZ]{3,9}\ /([^.]+)\.html\ HTTP
RewriteRule ^([^.]+)\.html$ /$1 [R= 301,L]
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html
#///
RewriteEngine On
RewriteRule ^index\.html$ /$1 [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
(answered my own question, well done)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question