Depending on your setup, you can have Apache rewrite the URL for you:
# Nice looking URLs (no query string)
# domain.com/category-name-1/ to domain.com/categories.php?name=category-name-1
RewriteRule ^([A-Za-z0-9-]+)/?$ categories.php?name=$1 [L]
In this example, you still get the value for "name" in your php like:
$name = $_GET['name'];
I got this from here btw
Just add additional '([A-Za-z0-9-]+)/' in your patten to match additional "levels." Keep in mind that the next match is rewritten with the $2 variable (and so on...)
The way I prefer to do this by is by forcing apache to parse a specific file as if it were a php page. The file has no extension and appears to be a subfolder in URL. Everything that comes after that is ignored by apache. However, you can access it via PHP and based on what is there, act accordingly.
Here's an example.