1
我想構建一個mod_rewrite URL,但似乎無法使查詢字符串與mod_rewrite規則一起工作。具有多個變量的HTAccess
我的代碼是:
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]
作品......我似乎無法讓我的頭周圍!
我後:
提名/平均
提名/會計師
提名/會計/平均
所以沒有辦法讓被提名人/會計師/平均人數和被提名人/平均值? – potts
@potts我沒有更改底部的規則,如果它是'nominees/accountants/average',它與底部的最後一條規則相匹配。但是,你應該如何區分'?order = average'和'?cat = average'之間的區別?兩者的URL看起來都一樣。 –
'nominees.php /?cat =會計師=/nominees/accountants'和'nominees.php /?order = average =/nominees/average' – potts