Home > Backend Development > PHP Tutorial > 本地怎么使用http authentication

本地怎么使用http authentication

WBOY
Release: 2016-06-13 12:57:04
Original
964 people have browsed it

本地如何使用http authentication
我在本地测试HTTP Authentication的时候无法登陆,放在买来的空间里却可以登录,请问本地如何使用authentication

我系统win 7

安装了apache 2.0  PHP 5.3 mysql 5.5

apache里的httpd.conf我也调用了AUTH,比如

LoadModule auth_module modules/mod_auth.so
LoadModule auth_anon_module modules/mod_auth_anon.so
LoadModule auth_dbm_module modules/mod_auth_dbm.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule autoindex_module modules/mod_autoindex.so

<br />
<?php<br />
$username = 'admin';<br />
$password = 'admin';<br />
if(isset($_SERVER['PHP_AUTH_USER']) &&<br />
   isset($_SERVER['PHP_AUTH_PW']))<br />
{<br />
	if($_SERVER['PHP_AUTH_USER'] == $username &&<br />
	   $_SERVER['PHP_AUTH_PW']	 == $password)<br />
	   echo "You are now logged in";<br />
	else die("Invalid username / password combination");<br />
}<br />
else<br />
{<br />
	header('WWW-Authenticate: Basic realm = "Restricted Section"');<br />
	header('HTTP/1.0 401 Unauthorized');<br />
	die("Please enter your username and password");<br />
}<br />
Copy after login

authentication module php header
------解决方案--------------------
参考apache关于.htaccess / .htpasswd 的相关文档
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template