Friendly URL with . htaccess

Asked

Viewed 1,383 times

-3

1 answer

1

Good from what I understand wants something easy way. It follows an easy way to do. However I really recommend studying and learning how htaccess works.

http://www.htaccesseditor.com/pt.shtml#a_fileList

https://httpd.apache.org/docs/2.2/pt-br/howto/htaccess.html

Rewriting URL by . htaccess: Extension . php

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

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

Rewriting URL by . htaccess: Extension . html

To remove ".html" from your URL and enjoy a user-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 part of the code that the "magic" of hiding the extension happens.

Browser other questions tagged

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