Escoder . php extension through . htaccess file

Asked

Viewed 716 times

1

I’m using the following code on a hostgator web server, but I can’t hide the extension .php. How to solve this?

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

1 answer

2

RewriteEngine On

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\\.php [L]

Of course this will not prevent the user from typing directly into the URL. /arquivo.php

Example of use.

You have a page http://foo.bar/home.php, then you can access how http://foo.bar/home

  • It worked! I was actually thinking that the function simply hid the extension. I took the extensions of some links that direct to the pages and it worked, no longer displays the extension, only the site has more than 200 links to eliminate the extension of each one...

Browser other questions tagged

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