Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top