当网址为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=$3
... param3的返回值为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
我该怎么做?
答案 0 :(得分:0)
试试这段代码。这可能不是你想要的(在正则表达式的层面上),但这是有效的:
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]