4

I am using PHP for my website, and .php is appearing in my URLs. How can I remove this?

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
Suraj
  • 59
  • 1
  • 6

2 Answers2

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:

… other options are probably available, but those are the ones that spring to mind.

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
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