【发布时间】:2010-11-21 06:04:19
【问题描述】:
我对如何构建产品列表页面、产品页面和网页有疑问。
大致翻译成这样:
-
/bags/nicebag.html=/product.php?product=nicebag&category=bags -
/nicebag.html=/product.php?product=nice_bag -
/bags=productlisting.php?&category=bags
问题是网页将与列表中的第 2 个网页共享相同的 URL 结构
/contact.html = page.php?page=contact
.htaccess 中没有单独列出的原因是网页可以有不同的名称。甚至同一个页面也可以有多种语言。
没有的原因。 1 和 2 没有结合,是因为有时我只想参考产品,因为它可以属于多个类别。
你建议什么样的结构?
.htaccess
# Mod rewrite enabled.
Options +FollowSymLinks
RewriteEngine on
# ---- Rules ----
# product.php (Search for category & product name)
RewriteRule ^([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)\.html?$ product.php?prod_id=$2&cid=$1 [NC,L]
# productlisting.php (Search for category)
RewriteRule ^([A-Za-z0-9-_]+)?$ productlisting.php?&cid=$1 [NC,L]
【问题讨论】:
标签: apache url .htaccess mod-rewrite