How to remove html extension from urls

Asked

Viewed 37 times

0

Hello. I built a website, but I can’t "hide" the "html" extension of the urls, even using, after a lot of research, the codes below in the -.htaccess file_.
Below follows the code inserted in .htaccess, including, I saw that other people, using the same nomenclature transcribed below, also did not succeed.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

1 answer

0

Try the code below. If it doesn’t work, there must be some block on your site’s server.

RewriteEngine on

RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]

Sample taken and tested from this answer: https://stackoverflow.com/a/34726322/15796509

Browser other questions tagged

You are not signed in. Login or sign up in order to post.