如何创建一个基于URL加载内容的页面[关闭]

I'm trying to create an easy product display system. I have a database of products which we are displaying on a single /shop.php page, it just lists all the products. But we're at the stage now where we need to have urls linking to products and so each product needs its own page. AKA /products/product1..product2..product3, but really in the backend it's only a product.php file which looks at the incoming/products/product url and creates the page via just that url, AKA the product SKU or ID or whatever primary key, would probably have to use the name because SKU urls look a bit weird. We are using .htaccess to redirect urls such as /shop /home /aboutus so urls such as /products/Bianco needs to display the product page for Bianco.

I hope you can help, thank you very much :)

I would suggest you to use iFrames.

https://www.w3schools.com/tags/tag_iframe.asp

Well, this is pretty straightforward.

On the Shop page, the product url would be : http:website.com/products/Bianco

And In your php script for the products page : products.php, you would do something like:

if(isset($_GET['product_name'])) {

    //filter and fetch the product name and get the product details from the database

} else {

   //404

}

The trick being, Friendly urls convert http:website.com/products/Bianco to http:website.com/products.php?product_name=Bianco

So, your script would still get the GET variable, which you then use to fetch the product details from the product database.