Created
May 24, 2014 14:49
-
-
Save 1stevengrant/5ee4913109dd0922ed74 to your computer and use it in GitHub Desktop.
add this to your CMS index file to protect a file
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