Good morning. I have a simple query. My question is the following one, this is the link of my web page (example)
link .html
So I want to make the link look like this:
Can you help me?
The options that Roberto gives you in the comment are valid, although not recommended or that can be more difficult, but there is a simpler way to do it and it is through the .htaccess
This file is located in the public root of your hosting, if there is not one you can create it and write the following code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]
This if you only work with extensions .html, if you work with .php or others you should add new lines for the corresponding extensions.
If you want your URL to end in bar \
then instead of the previous code you need to add the following:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.html
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
I leave the source link although is in English