I've seen that WordPress has a feature where you can change the permalink of your pages to different formats e.g. 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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top