0

当网址为www.xxx.com/theproblem/is-here.html. 我想得到is-here.html,但有这个规则....

RewriteRule ^([a-z\-\_A-Z0-9]+)/([^/]+)?(?<!\.html)\b/?(([^/]+)\.html)?$ this.php?param1=$1&param2=$2&param3=$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

我怎样才能做到这一点?

4

1 回答 1

0

试试这个代码。这可能不是您想要的(在正则表达式级别),但这是有效的:

RewriteEngine On
RewriteRule ^([^/]+)/([^/]+)/([^.].html)$ this.php?param1=$1&param2=$2&param3=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/$ this.php?param1=$1&param2=$2 [L]
RewriteRule ^([^/]+)/([^.].html)$ this.php?param1=$1&param2=$2 [L]
于 2013-06-20T09:43:11.163 回答