1

我对 .htaccess 有点问题。如果目录是安全的,或者任何安全的子目录/文件,我想停止 mod rewrite 生效。我已按如下方式设置 .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 rewrite,因为我需要对目录使用 htpassword。

4

1 回答 1

0

In per-directory-context, the slash is appended to the end of the directory (leaving the part that rewriterule matches without a leading slash). Your first rule will therefore never match. In this case I think you can simply have a negative condition using %{REQUEST_URI}.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/secure/
RewriteRule ^(.*)$ index.php/$1 [L]
于 2013-11-16T10:09:14.477 回答