新数据库条目时创建新产品页面
Create new productpage when new database entry
当我在数据库中输入新产品时如何创建新页面,或者将参数隐藏在普通的 /.../ 中?
在这个例子中,我将销售产品 ID 为 101010 的 Sandles
我不想像下面的例子那样使用参数:
example.com/shop?productid=101010
但我希望新页面是
example.com/shop/sandles
首先,您需要能够获取产品,而不是通过某些数字 ID (101010),而是通过像这样的 url 段 'my-unique-product-name'(升级您的服务器端代码)
现在你应该有这样的东西了:
example.com/shop?url=my-unique-product-name
然后将如下内容添加到您的 .htaccess 中:
RewriteRule ^shop/([A-Za-z0-9-_]+])$ shop.php?url= [L]
它告诉您的服务器以与 example.[=29= 相同的方式处理 URL-s like example.com/shop/my-unique-product-name ]?url=my-unique-product-name,如果这对你有意义。
阅读更多关于 .htaccess 的信息 URL 重写 here
当我在数据库中输入新产品时如何创建新页面,或者将参数隐藏在普通的 /.../ 中?
在这个例子中,我将销售产品 ID 为 101010 的 Sandles
我不想像下面的例子那样使用参数:
example.com/shop?productid=101010
但我希望新页面是
example.com/shop/sandles
首先,您需要能够获取产品,而不是通过某些数字 ID (101010),而是通过像这样的 url 段 'my-unique-product-name'(升级您的服务器端代码)
现在你应该有这样的东西了:
example.com/shop?url=my-unique-product-name
然后将如下内容添加到您的 .htaccess 中:
RewriteRule ^shop/([A-Za-z0-9-_]+])$ shop.php?url= [L]
它告诉您的服务器以与 example.[=29= 相同的方式处理 URL-s like example.com/shop/my-unique-product-name ]?url=my-unique-product-name,如果这对你有意义。
阅读更多关于 .htaccess 的信息 URL 重写 here