我有两页说
http://assistque.com/services.php?prod_id=35&prod_url=Operating%20System%20–%20Windows
和
http://assistque.com/sub_services.php?sp_id=13&sp_url=Technical%20Support%20For%20KASPERSKY
我为两个不同的页面编写了两个规则,但是第二个页面使用了第一个规则。
请帮忙
RewriteRule ^([^/]*)/([^/]*)\.html$ /services.php?prod_id=$1&prod_url=$2
RewriteRule ^([^/]*)/([^/]*)\.html$ /sub_services.php?sp_id=$1&sp_url=$2
答案 0 :(得分:0)
这是因为两个规则中的模式是相同的,尝试将它们更改为唯一的:
RewriteRule ^services/([^/]*)/([^/]*)\.html$ /services.php?prod_id=$1&prod_url=$2 [L]
RewriteRule ^subservice/([^/]*)/([^/]*)\.html$ /sub_services.php?sp_id=$1&sp_url=$2 [L]
然后在您的链接中添加以下内容:
<a href="http://exampel.com/services/35/operating-systems-windows.html">operating systems windows</a>
请注意,您不应在网址中使用空格,因此在这种情况下,我认为这些将替换为-
字符。
在重写规则中缩小允许的字符和数字也可能更好:
# will match services/<number>/<string>.html
# the NC flag states that the rule is case insensitive
RewriteRule services/([0-9]+)/([a-z-]+)\.html$ /services.php?prod_id=$1&prod_url=$2 [NC,L]