Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Zend:
Making the Web a Cleaner Place
Apr 24, 2003 @ 12:06:52

Over on Zend this morning, they have a new article for those out there that have been looking for a way to "clean up their act" on their site's URLs. Harnessing the power of PHP and Apache, you can (yes you!) make a site that has less of "foo.php?test=1" and more of "foo/test/1". Much cleaner, don't you think?

In this piece, the author shows you how to create these URLs, using the Files, ForceType, AcceptPathInfo directives in Apache. Files and ForceType allow you to make special instances for your PHP scripts, and tells Apache to treat them like a PHP interface, rather than just another PHP file. The AcceptPathInfo is something unique to this version of the "clean URLs" methods I've seen. This directive forces Apache to look down the URL string, trying to match the path to files as it goes. This can be handy if you want to use something with two different PHP files parsed as interfaces in the URL.

It's a pretty simple task to get these "clean URLs" up and working - I just wish more sites would take advantage of them. Not only would it make the internet a cleaner place, it can help the coders out there make cleaner code (take params out of $_GET and parse them from $_SERVER)...

tagged:

Link:


Trending Topics: