相关我以前的问题:.htaccess check for cookie first, then valid-userhttpd.conf代码无法正常工作 - 建议?
嗨,大家好,我真的很感谢这里的专家的一些帮助。我的httpd.conf应该要求用户使用mod_auth_mysql或cookie来登录 - 但现在它只是检查用户登录。上一个问题的代码现在位于我的httpd.conf中。
什么工作:
目前,用户都在/ var/WWW /下载和子目录(在/ var/WWW /下载/〜名〜)需要使用mod_auth_mysql用户名和密码。这工作。
什么是不工作:
的问题是:我应该需要设置要么使用mod_auth_mysql(作品)登录,或一个cookie(不工作)。如果cookie存在,那么当用户转到/ var/www/downloads /时,它应该自动显示目录的内容。但它不,它仍然要求用户名/密码。
我正在使用SetEnvIf,但它可能被错误地用于“满足所有”。我可能会在httpd.conf和/ sites-enabled/000-default之间发生冲突。我对这里的大部分内容都没有经验,所以任何帮助都会受到大力赞赏!
的httpd.conf:
RewriteEngine on
RewriteLogLevel 9
RewriteLog /var/www/logs/rewrite.log
#Block IPs
<Directory /var/www>
RewriteEngine On
#only use my server for apache
RewriteCond %{HTTP_HOST} !^2.2.2.2$ [NC]
RewriteRule ^(.*)$ http://www.google.co.uk/$1 [L,R=301]
RewriteCond %{REMOTE_ADDR} 0.0.0.0 [NC,OR]
RewriteCond %{REMOTE_ADDR} 1.1.1.1 [NC]
RewriteRule ^(.*)$ http://www.google.com [R]
</Directory>
# DOWNLOADS TOP DIRECTORY
<Directory /var/www/downloads>
#Options Indexes
#AllowOverride All
#Order deny,allow
#Deny from all
#Allow from All
AuthName "Please don't hack the server, thanks"
AuthBasicAuthoritative Off
AuthUserFile /dev/null
AuthMySQL On
AuthType Basic
Auth_MYSQL on
Auth_MySQL_Host localhost
Auth_MySQL_User user
Auth_MySQL_Password password
AuthMySQL_DB db
AuthMySQL_Password_Table users
Auth_MySQL_Username_Field username
Auth_MySQL_Password_Field password
Auth_MySQL_Empty_Passwords Off
Auth_MySQL_Encryption_Types Plaintext
Auth_MySQL_Authoritative On
require user luke
</Directory>
# EXAMPLE USERS DIRECTORY
# MIKE
<Directory /var/www/downloads/mike>
SetEnvIf Cookie (.*)cookiename(.*) norequire_auth=yes
Order Deny,Allow
deny from all
Satisfy Any
#MYSQL AUTH
AuthName "Please login"
AuthBasicAuthoritative Off
AuthUserFile /dev/null
AuthMySQL On
AuthType Basic
Auth_MYSQL on
Auth_MySQL_Host localhost
Auth_MySQL_User user
Auth_MySQL_Password password
AuthMySQL_DB db
AuthMySQL_Password_Table users
Auth_MySQL_Username_Field username
Auth_MySQL_Password_Field password
Auth_MySQL_Empty_Passwords Off
Auth_MySQL_Encryption_Types Plaintext
Auth_MySQL_Authoritative On
require user mike
#COOKIE AUTH
Allow from env=norequire_auth
</Directory>
如果它可以帮助,/ 000默认启用网站 - :可能会造成冲突? http://jsfiddle.net/Xcece/
我没有使用.htaccess文件。我已经改变了大量的指令,并且已经完全丧失了。
我不能为了我的生活找出它为什么不起作用 - 我不太了解可能存在的冲突,所以在正确的方向与解释的一点,所以我可以避免在将来会这样做很棒。谢谢。
我试过注释/完全删除网站启用/ 000默认内的所有指令,但这会停止一切正常工作,所以看起来像我坚持!继续尝试... – Jimbo
相当希望我不必为此付出代价(我的一半代表) - 我注意到在000-default中更改AllowOverride All并没有改变任何东西。无法弄清为什么cookie检测不起作用! – Jimbo