[英].htaccess multiple rewrites for same url
I have the following .htaccess file: 我有以下.htaccess文件:
# Turn rewrite engine on
RewriteEngine on
# Rewrite url
RewriteRule ^dashboard/(.*)/(.*) /beheer/dashboard.php?m=$1&f=$2
RewriteRule ^dashboard/(.*)/(.*)/(.*) /beheer/dashboard.php?m=$1&f=$2&id=$3 [L]
When I try to go to mydomain.com/beheer/dashboard/test/test
I'm redirected to the normal url of mydomain.com/beheer/dashboard.php?m=test&f=test
(When I only use the first rewrite else I get 404 error). 当我尝试去
mydomain.com/beheer/dashboard/test/test
我重定向到正常网址mydomain.com/beheer/dashboard.php?m=test&f=test
(当我只用第一重写其他我收到404错误)。 It might be interesting to know that for some links I also need to pass a third parameter. 知道某些链接我还需要传递第三个参数,这可能很有趣。 So for example:
mydomain.com/beheer/dashboard.php?m=user&f=delete&id=1
. 例如:
mydomain.com/beheer/dashboard.php?m=user&f=delete&id=1
。 So my question is why isn't this .htaccess file working? 所以我的问题是,为什么这个.htaccess文件不起作用?
Use end anchor $
in your regex: 在正则表达式中使用结尾锚
$
:
# Turn rewrite engine on
RewriteEngine on
# Rewrite url
RewriteRule ^dashboard/([^/]+)/([^/]+)/?$ /beheer/dashboard.php?m=$1&f=$2 [L,QSA]
RewriteRule ^dashboard/([^/]+)/([^/]+)/([^/]+)/?$ /beheer/dashboard.php?m=$1&f=$2&id=$3 [L,QSA]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.