htaccess rewriterule question
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.ph开发者_开发技巧p?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]
I use these lines and localhost/showCategory/
is OK, localhost/showCategory/0/1
is OK,
localhost/showCategory/0/2
stays on the first page...(same 0/1) not good
What is the problem?
When I delete this /[a-z\-_0-9\+]*
from the 3. and 4. line then it's OK,
but then is a problem with this URL: http://localhost/showCategory/627/prodaja-automobila
Your order is not correct as far as i can see: you should start with the rule involving the most variables, and end with the one with the least.
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]
精彩评论