简体   繁体   中英

How to change .php extension of website pages?

I have a website running on PHP. I want to remove the .php suffix from all of my webpages in such way that the user doesn't get to know what server side language is running.

How do I edit the displayed address in the address bar to not show the .php ?

With mod_rewrite in .htaccess:

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

Apache has a feature, 'MultiViews' that allows the server to choose the correct extension when none is supplied. In your .htaccess or httpd.conf , you can add this:

Options MultiViews

If you have a file at /path/to/blah.php , it can be accessed as merely /path/to/blah .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM