2
I created some pages .html
and put online. In the browser the file extensions are visible. However I want to hide them to make the urls more "friendly".
For example: instead of www.meusite.com/contato.html
I want you to appear only www.meusite.com/contato
.
Researching (including similar questions here on the site) I saw that this can or should be done through the following .htaccess
. In many tutorials or answers appears the code below, but it did not work with me.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
ps: I would not like to turn my pages .html
in .php
because they are static pages.
UPDATING:
I put the following code in the . htaccess file:
RewriteEngine On
RewriteRule ^([0-9A-Za-z-_]+)$ /$1.html
I took the test with the "contact" page and it worked. In index.html
I changed the tag a
which makes the link to the contact page as follows: <a href="contato.html">Contato</a>
for <a href="contato">Contato</a>
. That is, within the site, when linking a page with another, I removed the extensions from the files. Apparently it worked. This is recommended?
I had the same problem and solved it in the same way... that’s what several sites indicate, including this tutorial that I found very enlightening https://ajuda.locaweb.com.br/wiki/comandos-uteis-no-htaccess/
– Duarte August