简体   繁体   中英

Create new productpage when new database entry

How can I create a new page when I enter a new product in my database, or hide the parameter inside a normal /.../ ?

In this example I will sell Sandles with the product-id 101010

I do not want to use parameters like in the following example:

example.com/shop?productid=101010

But I would like the new page to be

example.com/shop/sandles

First of all you'll need be able to fetch product not by some numeric ID (101010), but by url segment like this 'my-unique-product-name' (upgrade your server side code)

Now you should have something like this working:

example.com/shop?url=my-unique-product-name

then add to your .htaccess something like this:

RewriteRule ^shop/([A-Za-z0-9-_]+])$ shop.php?url=$1 [L]

It tells your server to process URL-s like example.com/shop/my-unique-product-name in a same way as example.com/shop?url=my-unique-product-name , if that makes sense to you.

Read more about .htaccess URL rewrite here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM