htaccess重写规则麻烦
我无法让我的重写规则正常工作。.
ErrorDocument 404 /404.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^companies/
RewriteRule ^companies\/\?(.*)([A-Za-z]+) index.php?cpy=$1 [R=301,L,NC]
RewriteRule ^([0-9]+)/?$ index.php?cid=$1 [L]
RewriteRule ^([A-Za-z_]+)/?$ index.php?cat=$1 [L]
重写规则 域名.com/123 域名.com/abc 似乎工作正常,
但我无法上班的另一件事是 domain.com/companies/?list=this
似乎 apache 找不到匹配项
RewriteRule ^companies\/\?(.*)([A-Za-z]+) index.php?cpy=$1 [R=301,L,NC]
谁能帮我找出该规则有什么问题吗?或者如果是别的什么?
I am having troubles getting my rewrite rules to work correctly..
ErrorDocument 404 /404.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^companies/
RewriteRule ^companies\/\?(.*)([A-Za-z]+) index.php?cpy=$1 [R=301,L,NC]
RewriteRule ^([0-9]+)/?$ index.php?cid=$1 [L]
RewriteRule ^([A-Za-z_]+)/?$ index.php?cat=$1 [L]
The rewrite rules for
domain.com/123
domain.com/abc
seem to work ok,
but the other one I cannot get to work is
domain.com/companies/?list=this
It seems that apache doesn't find a match for
RewriteRule ^companies\/\?(.*)([A-Za-z]+) index.php?cpy=$1 [R=301,L,NC]
Can anyone help me figure out what is wrong with that rule? or if it is something else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
RewriteRule
通常与查询字符串不匹配。您可以使用
RewriteCond
对它们进行匹配,参数化匹配显示为%1、%2
等,例如。
RewriteRule
s do not match on query strings as a rule.You can match on them using
RewriteCond
with the parameterized matches appearing as%1, %2
, etc.eg.