Created
October 29, 2014 03:28
-
-
Save andypotanin/b664345a586ced09964a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <IfModule mod_rewrite.c> | |
| RewriteEngine On | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule ^([^?]*)$ /secure.php?path=$1 [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] | |
| </IfModule> |
This file contains hidden or 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
| <?php | |
| if( !isset( $_SERVER[ 'HTTP_AUTHORIZATION'] ) && isset( $_SERVER[ 'REDIRECT_HTTP_AUTHORIZATION' ] ) ) { | |
| $_SERVER[ 'HTTP_AUTHORIZATION' ] = $_SERVER[ 'REDIRECT_HTTP_AUTHORIZATION' ]; | |
| } | |
| list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6))); | |
| header( 'cache-control: no-cache' ); | |
| if (!isset($_SERVER['PHP_AUTH_USER'])) { | |
| header('WWW-Authenticate: Basic realm="My Realm"'); | |
| header('HTTP/1.0 401 Unauthorized'); | |
| echo 'Text to send if user hits Cancel button'; | |
| exit; | |
| } else { | |
| echo "<p>Hello, </p>".$_SERVER['PHP_AUTH_USER']; | |
| echo "<p>You entered as your password: </p>".$_SERVER['PHP_AUTH_PW']; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment