Friendly URL with .htaccess

-3

I would like to leave my url that is like this: link to stay like this link

You can leave someone to make a .htaccess file for me

    
asked by anonymous 26.03.2018 / 16:47

1 answer

0

Good thing I understand, I want something easy way. Here's an easy way to do it. However I really recommend studying and learning how htaccess works.

link

link

Rewriting URL through .htaccess: .php extension

To remove the ".php" from your URL and enjoy a friendly link, simply enter the following lines:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Rewriting URL through .htaccess: .html extension

To remove the ".html" from your URL and enjoy a friendly link, you can simply insert the following line:

RewriteRule ^([^\.]+)$ $1.html [NC,L]

If you compare the two codes you will notice that in the RewriteRule line there is a $ 1.php in the first example and a $ 1.html in the second. We realize that it is in this snippet of code that the "magic" of hiding extension happens.

    
26.03.2018 / 17:28