(htaccess)重写重定向冲突

时间:2013-03-01 01:22:24

标签: regex .htaccess apache2

我需要将我的网址从aaa / bbb / 123?param1 = 1& param2 = 2& etc重写为index.php?controller = aaa& action = bbb& id = 123& param1 = 1& param2 = 2&等

我的HTACCESS中有以下代码

RewriteRule ^([a-z,A-Z,0-9]+)/([a-z,A-Z,0-9]+)/([0-9]+)?(.*)$ /rewrite/index.php?controller=$1&action=$2&id=$3$4 [QSA,R]

RewriteCond %{REQUEST_URI}   !^/rewrite/index.php$
RewriteCond %{REQUEST_URI}   !^/rewrite/robots.php$
RewriteCond %{REQUEST_URI}   !^/rewrite/$
RewriteRule ^(.*)$ /rewrite/index.php?fake_page=$1 [QSA,R]

最后一个块与第一行冲突。我不明白为什么因为第一行以“/rewrite/index.php”开头吧?

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

我解决了这个问题!我错过了[ L ]标志:

RewriteRule ^([a-z,A-Z,0-9]+)/([a-z,A-Z,0-9]+)/([0-9]+)?(.*)$ /rewrite/index.php?controller=$1&action=$2&id=$3$4 [QSA,R,L]

非常感谢!