2013-06-20 26 views
0

當url爲www.xxx.com/theproblem/is-here.html時。我想is-here.html,但這一規則....htaccess和minus不起作用的url

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

...參數3的返回值是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

試試看看這個代碼。這可能不是正是你想要的(在正則表達式的水平),但這是工作:

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]