Zend framework htaccess脚本-不允许重写特定文件

Zend framework htaccess脚本-不允许重写特定文件,zend-framework,.htaccess,redirect,Zend Framework,.htaccess,Redirect,我有以下htaccess脚本: RewriteEngine on RewriteBase / RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(test|test1).* - [L] 我原以为: 将重定向到index.php 对 我早就料到了 不会重定向到i

我有以下htaccess脚本:

RewriteEngine on
RewriteBase /
RewriteRule !\.(js|ico|txt|gif|jpg|png|css)$ index.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule  ^(test|test1).*  - [L]
我原以为: 将重定向到index.php

我早就料到了 不会重定向到index.php

错。(我也被重定向了)

我错过了什么


非常感谢

重写规则总是按照指定的顺序进行评估。因此,您的两个URL都将匹配第3行中的重写规则。其他规则将不会得到评估。为了不重写测试文件,可以将最后三条规则放在最上面(即,RewriteBase命令的正下方)

但最后,您可能应该更多地使用RewriteConds,例如:

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^(test|test1)
# the following RewriteCond is probably redundant because of the prior -f check
RewriteCond %{REQUEST_FILENAME} !\.(js|ico|txt|gif|jpg|png|css)$

RewriteRule (.*) index.php