【问题标题】:Why is .htaccess letting为什么 .htaccess 让
【发布时间】:2013-11-29 14:22:51
【问题描述】:

.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。

【问题讨论】:

    标签: .htaccess mod-rewrite server-configuration


    【解决方案1】:

    在 per-directory-context 中,斜杠附加到目录的末尾(使 rewriterule 匹配的部分没有前导斜杠)。 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]
    

    【讨论】:

      猜你喜欢
      • 2012-08-03
      • 2016-10-02
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多