How to use httpauthentication locally

Source: Internet
Author: User
Tags http authentication
How to use httpauthentication locally I cannot log on when I test HTTP & nbsp; Authentication locally, but can log on when I put it in the purchased space. how can I use authentication locally? win & nbsp; 7. install apache & nbsp; 2.0 & nbsp; PHP & nbsp; 5.3 & nbsp; mysql & nbsp; 5.5. how to use http authentication locally
I cannot log on when I test HTTP Authentication locally, but can log on in the purchased space. how can I use authentication locally?

Win 7 in my system

Installed apache 2.0 PHP 5.3 mysql 5.5

In apache, httpd. conf also calls AUTH, for example

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


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

Authentication module php header


------ Solution --------------------
For more information about apache, see. htaccess/. htpasswd.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.