我试图构建一个mod_rewrite网址,但似乎无法让查询字符串与mod_rewrite规则一起使用。
我的代码是:
RewriteEngine On
Options -Multiviews
Options -Indexes
Options +FollowSymLinks
RewriteBase /
RewriteRule ^(.*)/$ $1 [L,R=301]
RewriteRule ^awards awards.php [L]
RewriteRule ^nominees/([a-z]*)?$ /nominees.php?order=$1 [L,QSA]
RewriteRule ^nominees/([a-z]*)?$ /nominees.php?cat=$1 [L,QSA]
RewriteRule ^nominees/([a-z]*)/([0-9]*)$ /nominees.php?order=$1&page=$2 [L,QSA]
RewriteRule ^nominees/([a-z]*)/([0-9]*)$ /nominees.php?cat=$1&page=$2 [L,QSA]
RewriteRule ^nominees/([a-z]*)/([a-z]*)/([0-9]*)$ /nominees.php?cat=$1&order=$2&page=$3 [L,QSA]
RewriteRule ^nominees/([a-z]*)/([a-z]*)$ /nominees.php?cat=$1&order=$2 [L,QSA]
RewriteRule ^nominees/([0-9]*)$ /nominees.php?page=$1 [L,QSA]
RewriteRule ^nominees nominees.php [L]
RewriteRule ^register register.php [L]
RewriteRule ^admin admin.php [L]
RewriteRule ^login login.php [L]
RewriteRule ^logout logout.php [L]
如果我删除
RewriteRule ^nominees/([a-z]*)?$ /nominees.php?cat=$1 [L,QSA]
然后
RewriteRule ^nominees/([a-z]*)?$ /nominees.php?order=$1 [L,QSA]
有效...我似乎无法理解它!
我之后:
提名/平均
被提名者/会计师
提名/会计师/平均
答案 0 :(得分:0)
两个规则的正则表达式完全相同,这意味着第一个规则将匹配,第二个规则绝对不会执行任何操作。这适用于完全相同的每个集合。您需要一些其他限定符来区分" order"和#34; cat"参数。也许有些东西:
RewriteRule ^nominees/order/([a-z]*)?$ /nominees.php?order=$1 [L,QSA]
RewriteRule ^nominees/cat/([a-z]*)?$ /nominees.php?cat=$1 [L,QSA]
RewriteRule ^nominees/order/([a-z]*)/([0-9]*)$ /nominees.php?order=$1&page=$2 [L,QSA]
RewriteRule ^nominees/cat/([a-z]*)/([0-9]*)$ /nominees.php?cat=$1&page=$2 [L,QSA]
RewriteRule ^nominees/([a-z]*)/([a-z]*)/([0-9]*)$ /nominees.php?cat=$1&order=$2&page=$3 [L,QSA]
RewriteRule ^nominees/([a-z]*)/([a-z]*)$ /nominees.php?cat=$1&order=$2 [L,QSA]