I am using PHP for my website, and .php
is appearing in my URLs. How can I remove this?
Asked
Active
Viewed 5,170 times
2 Answers
6
There are lots of ways you could achieve this, but they depend largely on your choice of web server.
If, for instance, you were using Apache HTTPD you could use:
- MultiViews or
- AddHandler (e.g. inside Files or FilesMatch) or
- Alias or
- mod_rewrite
… other options are probably available, but those are the ones that spring to mind.
4
Create a file called .htaccess ( the dot in .htaccess is not an accident ) and enter the following:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(.*).php$
RewriteRule ^(.*)$ %1 [L,QSA]
Then save the file and place it a the root directory of your website.

Mani Muridi
- 400
- 4
- 18
-
what do i do if i have .html extension? I tried to change the .php to .html but its not working. – Suraj May 28 '13 at 03:05
-