2012-08-12 76 views
0

使用Apache,我强迫HTTPS的文件夹上:的.htaccess “从ENV允许” 禁用SSLRequire

SSLOptions +StrictRequire 
SSLRequireSSL 
SSLRequire %{HTTP_HOST} eq "www.example.com" 
ErrorDocument 403 https://www.example.com/admin/ 

我保护使用Apache AuthBasic的文件夹:密码

AuthType Basic 
AuthName "Administration" 
AuthUserFile /path/to/my/.htpasswd 
Require valid-user 
Satisfy all 

这样,始终通过HTTPS发送。它工作得很好,但后来我尝试为一个单一的URL禁用验证:

SetEnvIf Request_URI "crm/index\.php$" removeme_uri 
Order deny,allow 
Deny from all 
Allow from env=removeme_uri 
Satisfy any 

此网址不要求进行身份验证,和其他人做。所以一切都很好,但不再需要HTTPS,密码可以发送清晰!

我在这里做错了什么?

回答

1

感谢Jon的回答,我可以尝试不同的解决方案。我发现this question和应用的答案,我的情况:

在主目录和.htaccess包含

SSLOptions +StrictRequire 
SSLRequireSSL 
SSLRequire %{HTTP_HOST} eq "www.example.com" 
ErrorDocument 403 https://www.example.com/admin/ 

AuthType Basic 
AuthName "Administration" 
AuthUserFile /path/to/my/.htpasswd 
Require valid-user 
Satisfy all 

而在crm子目录和.htaccess有:

<FilesMatch "index\.php"> 
    Allow from all 
    Satisfy any 
</FilesMatch> 

它无论如何强制SSL,并允许访问crm/index.php

0

这有点奇怪,因为Satisfy指令影响访问限制,并且尽管SSLRequireSSLSSLRequire影响SSL,但它们被认为是访问限制的一部分。所以当你在允许访问一个URI而不需要有效用户的情况下使用Satisfy Any时,它也使得它的访问需求是Any的一部分。由于Satisfy的选项是AllAny,所以不能说“总是这个,而是其他2个”。

您可能需要使用类似的mod_rewrite强制SSL在你的htaccess文件:

RewriteEngine On 
RewriteCond %{HTTPS} !on 
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] 
+0

嗨,乔恩,谢谢你的回答!我试过你的解决方案,但不幸的是它没有工作。不过,我能够进一步探索并找到一种方法:) 我想upvote你的答案,但我没有足够的声望呢。对不起:/ – 2012-08-15 21:08:28