Created
August 5, 2014 18:12
-
-
Save 1stevengrant/3543ecf9f9382fe65820 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if($_SERVER['SERVER_ADDR'] == '127.0.0.1') { | |
$username = 'username'; | |
$password = 'password'; | |
if (!(isset($_SERVER['PHP_AUTH_USER']) && ($_SERVER['PHP_AUTH_USER']==$username && $_SERVER['PHP_AUTH_PW']==$password))) { | |
header('WWW-Authenticate: Basic realm="This site is protected"'); | |
header('HTTP/1.0 401 Unauthorized'); | |
// Fallback message when the user presses cancel / escape | |
echo 'Access denied'; | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment