I have been thinking for quite some time now about how I could manage thousands of webpages that change based on a set of data in MySQL.
So in essence, I have thousands of "products" and each is represented by a row in a database table.
What I do currently to page each of these "products" viewable via a url is place a .php file in the url location so that when a user visits http://www.mydomain.com/some_random_product.php
they are opening one of many .php files that all contain the following:
<?php
$thisPageName = basename(__FILE__, ".php");
include '/out/of/root/allProducts.controller.php';
?>
So essentially all is hand off the url name to another script that takes the url name then searches the database for a corresponding "product", if it finds the product then it displays a product page with the relevant information and if not it displays an error page stating that the product could not be found.
What I would like to do now, is better that process so that I would not need to create thousands of physical files on the server. Even though this is quite a simple task as I have a script to do it, it just becomes a pain having to run the thing all the time (I have to do it locally as it is a resource hog, then copy all the pages across to the server).
Possibly just one file that all of the urls in that location would load without changing the url as I need it to find the relating info.
I would like to add that the server running the domain is a VPS that I have full access to and I understand that the Apache mod_rewrite module may be of use here but I honestly would not know where to even start in terms of the logic behind implementing that.
If anyone could suggest a better way to do this or anything that may be of relevance then it would be greatly appreciated, thank you!