【问题标题】:Multi Level Pretty URL for E-Commerce Products In htaccesshtaccess 中电子商务产品的多级漂亮 URL
【发布时间】:2016-10-07 21:55:43
【问题描述】:

更新版本 我正在开发一个电子商务门户网站,其中的产品需要以漂亮的 url 和类别显示。

我当前的链接: http://abcd.xyz/products.php?pro_tag=1221212112(假链接)

我的目标: http://abcd.xyz/products/1221212112(假链接)

我当前的 HTACCESS 代码。 (在其他 Stackoverflow 建议的帮助下完成):

RewriteEngine On
RewriteBase /
RewriteRule ^products/([a-zA-Z0-9-]+)/?$ products.php?pro_tag=$1 [QSA,NC,L]
RewriteRule ^products/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ products.php?pro_tag=$2&ctg=$1 [QSA,NC,L]

找出问题所在:未获取“pro_tag”。需要帮助来解决这个问题。

【问题讨论】:

  • 有问题吗?
  • 是的。当我使用链接时:abcd.xyz/1221212112,它正在从数据库中加载数据以及一些 CSS 问题,但是当我使用我的 GOAL Link 时,它没有加载数据。

标签: php .htaccess


【解决方案1】:

尝试:

RewriteEngine On
RewriteBase /
RewriteRule ^products/([a-zA-Z0-9-]+)/?$ products.php?pro_tag=$1 [QSA,NC,L]
RewriteRule ^products/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+)/?$ products.php?pro_tag=$2&ctg=$1 [QSA,NC,L]

我添加了一个ctg 变量...

【讨论】:

  • 不!不工作!
  • 您的products.phpproducts 目录中?
  • 不!它是 index 目录中的一个普通 products.php 页面。
  • 刚刚用您的代码再次测试。现在即使 abcd.xyz/1221212112 这个链接也不起作用。而且我的 GOAL Link 也不能正常工作。
  • 你尝试使用http://abcd.xyz/products/1221212112 而不是http://abcd.xyz/1221212112 !!! (在你的问题中)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-07
  • 1970-01-01
  • 2023-02-26
  • 2019-02-22
  • 2012-05-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多