Archive for the ‘HowTo’s’ Category

URL prettification in 10 seconds flat

November 29th, 2008 No comments

A word to all PHP, ASP, Python and Perl web-devs out there:

Is soooo 1990’s.

URL prettification has always been seen to be the exclusive domain of larger frameworks but with Apache it really isn’t that hard.

Simply paste the following into a file named ‘.htaccess’ (note the starting ‘dot’) and dump it in your website to allow the extension of your script to be ‘guessed’ by Apache should it not be provided.

This hack obviously requires mod_rewrite but since every hosting provider and their dog provides this these days i would say not having it enabled would be the exception rather than the rule

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$		$1.php [L]

ASP, Python and Perl people either add your .asp, .py or .pl sections under or above the .php bits or simply replace them.

There, now we can use:

But the old way (with .php extension) is still valid too.

Finally we put an end to this silly file extension nastiness.

Categories: HowTo's, PHP Tags: , ,