如何为基于Drupal的Web应用实施HTTP身份验证以限制访问,例如仅适用于开发人员?
答案 0 :(得分:2)
答案 1 :(得分:1)
$LoginSuccessful = false;
if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])){
$Username = $_SERVER['PHP_AUTH_USER'];
$Password = $_SERVER['PHP_AUTH_PW'];
if ($Username == 'username_test' && $Password == 'password_test'){
$LoginSuccessful = true;
}
}
// Login passed successful?
if (!$LoginSuccessful){
header('WWW-Authenticate: Basic realm="Secret page"');
header('HTTP/1.0 401 Unauthorized');
print "Login failed!\n";
exit();
}
解决了我的问题.. thnks ...
答案 2 :(得分:0)
如果Apache的htaccess足够你,请阅读here。