【发布时间】:2012-10-24 11:14:18
【问题描述】:
我的 apache 服务器上有一个目录的 .htaccess 文件。目前这使用 mod_auth_mysql 进行用户验证以查看目录列表。但是,如果用户已经登录到我的应用程序(因此存在 cookie),我想跳过有效用户要求,从而消除多次登录。
当前 .htaccess
AuthName "Please don't hack the server, cheers"
AuthBasicAuthoritative Off
AuthUserFile /dev/null
AuthMySQL On
AuthType Basic
Auth_MYSQL on
Auth_MySQL_Host localhost
Auth_MySQL_User username
Auth_MySQL_Password password
AuthMySQL_DB auth
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 james
Cookie 检查
RewriteEngine On
RewriteCond %{HTTP_COOKIE} !^cookiename=ok$
RewriteRule .* / [NC,L]
如何正确结合这两者,首先检查 cookie,如果找到则允许通过,然后如果未找到 cookie,则检查有效用户?
谢谢
【问题讨论】: