Hiding .php extensions in URL

Hi,

I need to know if there is anyway we can hide the .php extension in the URL
eg:

http://example.com/dmca.php
http://example.com/contact.php

changed urls look like

http://example.com/dmca
http://example.com/contact

and also if there is a way to change this url

http://example.com/example.php?search=example+search+term

like this

http://example.com/example/example+search+term

:shifty:

Hi CJ4,

Yes indeed there are ways to do this, but it depends on what server software you are using. In the case of Apache web server, then it needs to have the module mod_rewrite installed (follow the link for docs on how to configure it).

Nginx and [URL=“http://www.iis.net/learn/extensions/url-rewrite-module”]IIS have similar modules too (though I suppose using PHP on IIS is unlikely, it is possible!).

You should bear in mind though that “security by obscurity is no security at all”, and there are plenty of other ways that an attacker can determine that you are using PHP. If it is more SEO that you’re concerned with, then your second example (search URIs) is not really applicable as you can screen those from search engines anyway.

CJ,

First, WELCOME to SitePoint!

Now that you’re here and asking about mod_rewrite (whether you knew it or not), have a read of the mod_rewrite tutorial linked in my signature. It was built after answering repeated questions for years in this board and should give you all the basic (and some advanced) information you need to do just about anything with this tremendous Apache tool. It’s helped many members over many years so I’m sure it’ll help you, too.

Regards

DK