W
W
wakenbyWork2022-03-24 13:07:55
htaccess
wakenbyWork, 2022-03-24 13:07:55

How to make universal htaccess to remove html from path?

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


Here is a cat that removes html from the address path, and now I want to not prescribe myDomain.ru every time, how can I rewrite it so that, regardless of the domain, it is not necessary to write .html?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2022-03-24
@wakenbyWork

RewriteRule ^([^.]+)\.html$ myDomain.rul/$1 [R=301,L]

The domain can be removed completely and left only Or take the domain from% {HTTP_HOST}/$1
RewriteRule ^([^.]+)\.html$ /$1 [R=301,L]
RewriteRule ^([^.]+)\.html$ https://%{HTTP_HOST}/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question