htaccess和minus在网址中不起作用

时间:2013-06-20 09:00:43

标签: .htaccess

当网址为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

我该怎么做?

1 个答案:

答案 0 :(得分: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]