当url为www.xxx.com/theproblem/is-here.html时。我想要得到is-here.html,但是有了这个规则...
RewriteRule ^([a-z\-\_A-Z0-9]+)/([^/]+)?(?<!\.html)\b/?(([^/]+)\.html)?$ this.php?param1=$1¶m2=$2¶m3=$3param3的...the返回值为here.html。这是因为参数2得到了is-。
为什么会发生这种情况?
我想实现这个目标:
www.xxx.com/theproblem/is-here.html. -> param1=theproblem | param2=is-here.html
www.xxx.com/theproblem/why-this/ -> param1=theproblem | param2=why-this
www.xxx.com/theproblem/why-this/is-here.html. -> param1=theproblem | param2=why-this | param3=is-here.html我该怎么做呢?
发布于 2013-06-20 17:43:11
试试这段代码。这可能不是您想要的(在正则表达式级别),但这是有效的:
RewriteEngine On
RewriteRule ^([^/]+)/([^/]+)/([^.].html)$ this.php?param1=$1¶m2=$2¶m3=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/$ this.php?param1=$1¶m2=$2 [L]
RewriteRule ^([^/]+)/([^.].html)$ this.php?param1=$1¶m2=$2 [L]https://stackoverflow.com/questions/17209449
复制相似问题