/dogs/monkies/chickens/
/dogs/
/ (home page)
These links may or may not have the trailing slash and the depth of the link ( as I show above) is not always the same, ie there may be a link to /dogs/monkies/chickens/goats/farmers/ (that's 5 levels).
I would like to redirect those requests to reflect the file structure, which is:
/_pages/dogs/monkies_chickens.php or
/_pages/dogs/dogs.php
so a request for /dogs/monkies/chickens should go to /_pages/dogs/monkies_chickens.php
and a request for /dogs/ (or just /dogs) should go to
/_pages/dogs/dogs.php
Is this just a completely convoluted way of structuring a site? Essentially, I want all urls and links to look like /dogs/monkies/ etc, but I don't want to have to create so many separate directories and name all my files index.php. I also don't want to channel all requests through one index page that then includes the correct content. I have tried to below rule:
- Code: Select all
Options +FollowSymlinks
RewriteEngine on
# Match up to 3 levels
RewriteRule ^([^/]*)/?([^/]*)/?([^/]*)/? _pages/$1/$2_$3.php [R]
but this gives me strange errors; I fear I simply don't understand how it all works well enough. If anyone has any suggestions as to how to achieve this, or a different way of structuring the site, please let me know, I would greatly appreciate it.[/code]