【发布时间】:2018-10-09 09:30:45
【问题描述】:
我在我的.htaccess 文件中插入了这条规则:
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?content=category&categoryname=$1 [NC,L]
通过这种方式,我可以获得这样的友好网址: http://localhost/mysite/london
我还想为我的联系页面使用一个友好的 URL,如下所示: https://localhost/mysite/index.php?content=message 成为: https://localhost/mysite/contact
但如果我将以下规则插入.htaccess...
RewriteRule ^contact/?$ index.php?content=message [NC,L]
...它不起作用,因为类别的规则似乎会影响此规则。
其实如果我把分类规则注释掉的话……
#RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?content=category&categoryname=$1 [NC,L]
...联系页面的 url 友好规则有效 (https://localhost/mysite/contact)
所以我正在寻找从类别规则中排除某些参数的可能性,以便在某些情况下允许重定向到另一个 url。
感谢您的任何建议...
【问题讨论】:
标签: php .htaccess url-rewriting