mod_rewrite规则问题

时间:2011-03-21 13:38:51

标签: apache mod-rewrite

我有两个简单的mod重写规则

RewriteRule club/(.*)-(.*).html$ club.php?id=$2&%{QUERY_STRING}
RewriteRule club/details/(.*)-(.*).html$ /club/details.php?id=$2&%{QUERY_STRING}

第一个起作用,但第二个起作用。我认为第一个覆盖第二个,但我无法弄清楚如何解决它

3 个答案:

答案 0 :(得分:0)

RewriteRule club/(.*)-(.*).html$ club.php?id=$2&%{QUERY_STRING} [L]
RewriteRule club/details/(.*)-(.*).html$ /club/details.php?id=$2&%{QUERY_STRING}

尝试一下。

答案 1 :(得分:0)

尝试

RewriteRule club/(.*)-(.*).html$ club.php?id=$2 [L,QSA]
RewriteRule club/details/(.*)-(.*).html$ club/details.php?id=$2 [L,QSA]

答案 2 :(得分:0)

你可以试试几件事。一种是重新排序规则:

RewriteRule club/details/(.*)-(.*).html$ /club/details.php?id=$2&%{QUERY_STRING}
RewriteRule club/(.*)-(.*).html$ club.php?id=$2&%{QUERY_STRING}

另一种方法是更改​​模式,使正斜杠与俱乐部名称不匹配,如下所示:

RewriteRule club/([^/]*)-(.*).html$ club.php?id=$2&%{QUERY_STRING}
RewriteRule club/details/(.*)-(.*).html$ /club/details.php?id=$2&%{QUERY_STRING}