Tuesday, May 12, 2009

How to hide the .php extension in your URLs

Sometime you could implement web components that expose public REST-ful interfaces implemented in PHP. In those cases it may be useful to expose end points that are technology-agnostic. 

So, for example, instead of http://example.com/handler.php?param1=val1&param2=val2 you'd have http://example.com/handler?param1=val1&param2=val. Thus, you could later on decide to switch the underlying technology to something like servlets and reuse the old format for the URLs.

An easy way to accomplish this is using Apache's ability to do URL rewriting. Simply edit the .htaccess file in the root folder of your web directory and place the following directives:

RewriteEngine on 
RewriteRule handler handler.php

1 comment:

Unknown said...

The Most Iconic Video Slots On The Planet - Jancasino
The most iconic video slot febcasino.com is the 7,800-calibre slot machine called titanium metal trim Sweet filmfileeurope.com Bonanza. This slot machine was jancasino.com developed in 2011, developed in the same studio by