.htaccess 访问重写规则问题

.htaccess 访问重写规则问题,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我使用这些行,localhost/showcontegory/正常,localhost/showcontegory/0/1正常, localhost/showCategory/0/2保留在第一页…相同的0/1不好 有什么问题 当我从3中删除这个/[a-z\-\U 0-9\+]*时。四,。那就行了 但是这个URL有一个问题:据我所知,您的顺序不正确:您应该从包含最多变量的规则开始,然后以包含最少变量的规则结束 RewriteRule ^([a-z]{2}/){0,1}showCategory/([

我使用这些行,localhost/showcontegory/正常,localhost/showcontegory/0/1正常, localhost/showCategory/0/2保留在第一页…相同的0/1不好 有什么问题

当我从3中删除这个/[a-z\-\U 0-9\+]*时。四,。那就行了


但是这个URL有一个问题:

据我所知,您的顺序不正确:您应该从包含最多变量的规则开始,然后以包含最少变量的规则结束

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]

我想你可以去掉/{0,1}周围的括号。并确保您正确使用反向引用,我指的是$之后的数字。请发布应该解析的URL示例,包括所有变量和示例值,类似于>>showcontegory.php?id=627&il[lang]=en&page=4,还有一个示例,其中包含/mp/。array3{[id]=>string2 44[il]=>&array1{[lang]=>string0}[sh]=>&NULL}array3{[id]=>string2 44[il]=>&array1{[lang]=>string3 en/}[sh]=>&NULL}=>string0}[sh]=>&NULL}[page]=>string2 10缺失…不在评论中,请编辑您的问题。更具可读性。同样的问题。。。var_dump$\u GET不带这个/[a-z\-\u 0-9\+]*array4{[id]=>string10[il]=>&array1{[lang]=>string0}[page]=>string12[sh]=>&NULL}带:array3{[id]=>string10[il]=>&array1{[lang=>string0}[sh]>&NULL}像这样的事情没有意义:page=$3和$4$4将永远不会被拾取我第一次使用rewriterule,那么该怎么办呢?好的:脚本需要什么变量?array4{[id]=>String10[il]=>&array1{[lang]=>string0}[page]=>String12[sh]=>NULL}
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]