我对.htaccess有点问题。如果目录是安全的,或者任何安全的子目录/文件,我想停止mod重写生效。我已按如下方式设置.htaccess:
RewriteEngine On
RewriteBase /
#skip next rule if url starts with secure/
RewriteRule ^/secure/(.*) - [L,S]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<Files 403.shtml>
order allow,deny
allow from all
</Files>
有没有人知道它为什么不起作用?我不能只关闭mod重写因为我需要使用htpassword作为目录。
答案 0 :(得分:0)
在每个目录上下文中,斜杠被附加到目录的末尾(使得重写者匹配的部分没有前导斜杠)。 Your first rule will therefore never match.在这种情况下,我认为您可以使用%{REQUEST_URI}
简单地处于否定状态。
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/secure/
RewriteRule ^(.*)$ index.php/$1 [L]