Forum Moderators: phranque
I have a database-driven website consisting of a template.php page and an index.php page. The navigation for the site is pulled from the database and pages are created on-the-fly once requested.
The way this works is, the index page populates with nav items (drawn from MySQL) - when you click on a nav item the new page pulls the appropriate content and populates the template.php page. I'm using mod rewrite to convert the name of the template.php page to /nav-name/index.php
This is the line I do this with:
RewriteRule ^(.*)/index.php(.*)$ /template.php?page=$1
So with 10-pages of content in the SQL table, there's an index page in the root folder, and 9 more sub-folders with index pages of their own, which are really just mod-rewritten template.php pages.
What I'd LIKE to do is, instead of generating the pages in a folder (/nav-name/index.php) I'd like to keep them in the root folder - www.example.com/nav-name.php and still be able to populate the template page with the appropriate content.
Is this possible to do using mod rewrite, and if so - how?
Then modify your rewriterule to change requests for '/nav-name.php' to '/template.php?page=nav-name' instead of rewriting '/nav-name/index.php' to '/template.php?page=nav-name'. You will have to add an exclusion for template.php itself, so that it doesn't get rewritten itself, creating an infinite loop -- See RewriteCond %{REQUEST_URI} to get started on the exclusion part.
Once you accomplish this, you'll probably want to redirect all of your old URLs to the new scheme. That's another subject, and one you should probably ignore until you get the main problem worked out.
Jim