尝试实施一个非常简单的保护区域。我有两个php文件:
第一个:secure.php
<?php
$username = 'user';
$password = 'password';
if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW']) ||
($_SERVER['PHP_AUTH_USER'] != $username) || ($_SERVER['PHP_AUTH_PW'] != $password)) {
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Secure Area"');
exit('You are not authorized');
}
?>
和第二个:hello.php
<?php
require_once('secure.php');
?>
<doctype! html>
<head>
</head>
<body>
<p>hello</p>
</body>
</html>
访问hello.php时,系统会提示我输入用户名/密码。但我没想到的是经常被拒绝访问。
You are not authorized
Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
铬和野生动物园。有什么明显的东西我不见了吗?