I am currently building my own (very small) CMS. I am using PHP/MySQL and mod_rewrite for dynamically fetching the page requests from the database.
So far I had a plain structure like:
domain.com/page
This all works perfectly fine. But now I want to add "folders" or "categories".
The table has the needed fields (simplified):
id, name, pid (parent id)
I also worked out how to build the navigational structure from the database, but what I did not figure out so far is, how to get the requested page from the database by using mod_rewrite and PHP.
- How do I get the requested URLs like
domain.com/folder1/page
or more complexdomain.com/folder1/folder2/folder3/.../folderN/page
- How can I differ the document "page" in "folder1" from the document "page" in "folderN"?
- How do I treat not existing folders, like "folder2" in the example above?
Uhm, honestly I am a little bit helpless at the moment and hope someone here is willing to help me. :-)
Of course I googled and searched in stackoverflow, but I did not find any specific help. Links to tutorials are also welcome.
Thanks in advance & best regards!