As part of a project, we're currently looking at adding in SEO URLs to pages. This is for an online store, and there are numerous types of content within the site: static pages (for example "About Us", "Privacy Policy", product categories and product pages.
We have the numerous URL stubs stored in a MySQL table as follows:
+-----------------+------------------+----------------+
| url_stub | destination type | destination_id |
+-----------------+------------------+----------------+
| privacy-policy/ | page | 1 |
+-----------------+------------------+----------------+
| category-1/ | category | 2 |
+-----------------+------------------+----------------+
| my-product-1/ | product | 1 |
+-----------------+------------------+----------------+
One option to serve these up would be to have a huge index.php file which is capable of handling everything, however, we would much prefer to have separate pages to serve up the different content types. For example anything with a destination_type of page would go to page.php?id=#, and so forth. So, for the examples in the table above, these would be directed as follows:
privacy-policy/ = page.php?id=1
category-1/ = category.php?cat=2
my-product-1/ = product.php?prod=1
My question is this: what would be the best practice to achieve this? We don't want to include the destination_id anywhere in the SEO-friendly URL. I was thinking that it might be possible to create a dynamic .htaccess file which outputs everything on the fly with mod_rewrite, but I can't find any solutions.
Any help or comments would be most gratefully received.