How to get the .html from a link on my website

0

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:

  

link

Can you help me?

    
asked by SWAT 17.08.2017 в 03:21
source

1 answer

3

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

    
answered by 17.08.2017 в 04:19