简体   繁体   中英

How to change permalink for php pages in localhost

I've seen that WordPress has a feature where you can change the permalink of your pages to different formats eg www.example.com/index.html to www.example.com/index .

How do you do that in localhost or in general any host without using WordPress for example if I have the page www.example.com/about.php I want it to be search in a browsers address bar as www.example.com/about

Is there a way to do this?

Use .htaccess

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

The code above will get rid of the .php extension, thus giving you say index instead of index.php . And yes it works on localhost and nearly all hosting companies include it.

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