Path splitter

Problem:

How do you get those neat-o URIs with php, that all the Rails guys are bragging about? And without having loads of folders with index.php-files? Or learning to write cryptic mod_rewrite?

Solution

Make one php page take all requests, and serve accordingly. Do like Rails and use .htaccess. Like this:

# gentlemen, start your engines
RewriteEngine on

# send everything else to the index file
RewriteRule ^(.*)$ index.php

Then use the little bit of php code I have gathered here to parse the URI, and split it into an array. Then? Use your imagination to include what you need. A simple example (no includes, though) is right in the menu of this document.

Source

Get it right here, right now!

Credits

By Geir Arne Brevik for Kulturbyrået Mesén August 7th 2006.