views:

25

answers:

1

Currently I can not show site structure in the url IE www.site.com/parent-page/child-page without creating a subdirectory at the root. Is there an easy way to dynamically create the parent to child relationship other than creating subdirectories?

A: 

It really depends on what you're doing. If each page is its own script, then the directory structure probably helps keep things sane - I'm not sure there's a way to remove the directories and still keep the files in order.

But if you're using some kind of bootstrap you can simply rewrite all non-existing files/directories to a script. That script (or a script it calls) would then be responsible for parsing the request and determining what page to display.

This sample mod_Rewrite is taken from the end of this Zend Framework section:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Apache's mod_rewrite docs are a good reference.

Tim Lytle