[nycphp-talk] Friendly URLS... The easy way!

Paul Houle paul at
Mon Aug 6 21:19:02 EDT 2007

There's an easy way to get 'friendly' URLs in PHP.  There are two tricks 

(1) It seems to be a bit obscure that if you have a PHP script at

the same script is called if you visit

Try it!  You can make your script display something different based on 
the path
you enter by checking the superglobal $_SERVER["PATH_INFO"].  From simple
if-then-else ladders to advanced frameworks,  you can take it from there 
as you wish.

(2) You can remove the ".php" from your scripts by putting the following 
in your
.htaccess or apache configuration:

DefaultType application/x-httpd-php

Now if you have a script without an extension (say,  "myscript") you can 

More information about the talk mailing list