htaccess rewriterule问题

时间:2010-02-03 10:07:56

标签: .htaccess mod-rewrite

RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)/[a-z\-_0-9\+]*/mp/(.*)(/{0,1})$ /main.php?id=$2&il[lang]=$1&$3 [L]

RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)/[a-z\-_0-9\+]*/(.*)/mp/(.*)(/{0,1})$ /main.php?id=$2&il[lang]=$1&page=$3&$4 [L]

RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)(/{0,1})/[a-z\-_0-9\+]*$ /main.php?id=$2&il[lang]=$1 [L]

RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)/[a-z\-_0-9\+]*/([0-9]*)(/{0,1})$ /main.php?id=$2&il[lang]=$1&page=$3 [L]

RewriteRule ^([a-z]{2}/){0,1}showCategory$ /main.php?id=0&il[lang]=$1 [L]

我使用这些行,localhost/showCategory/没问题,localhost/showCategory/0/1没问题, localhost/showCategory/0/2停留在第一页......(相同的0/1)不好 有什么问题?

当我从3.和4.行中删除此/[a-z\-_0-9\+]*时,就可以了,

但此网址存在问题:http://localhost/showCategory/627/prodaja-automobila

1 个答案:

答案 0 :(得分:0)

据我所知,您的订单不正确:您应该从涉及大多数变量的规则开始,并以最少的变量结束。

RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)/[a-z\-_0-9\+]*/(.*)/mp/(.*)(/{0,1})$ /main.php?id=$2&il[lang]=$1&page=$3&$4 [L]


RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)/[a-z\-_0-9\+]*/([0-9]*)(/{0,1})$ /main.php?id=$2&il[lang]=$1&page=$3 [L]

#----------------------------
#Not sure this one is correct, if it is, it should be here i guess
#----------------------------
RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)/[a-z\-_0-9\+]*/mp/(.*)(/{0,1})$ /main.php?id=$2&il[lang]=$1&$3 [L]



RewriteRule ^([a-z]{2}/){0,1}showCategory/([0-9]*)(/{0,1})/[a-z\-_0-9\+]*$ /main.php?id=$2&il[lang]=$1 [L]

RewriteRule ^([a-z]{2}/){0,1}showCategory$ /main.php?id=0&il[lang]=$1 [L]