Voting

: seven minus seven?
(Example: nine)

The Note You're Voting On

h3ndrik
11 years ago
On my configuration with php-cgi - after setting the RewriteRule - the correct variable would be: $_SERVER['REDIRECT_HTTP_AUTHORIZATION']

So the workaround for PhpCGI is:
Set in your .htaccess:

RewriteEngine on
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]

Php workaround:
<?php
//set http auth headers for apache+php-cgi work around
if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) {
    list(
$name, $password) = explode(':', base64_decode($matches[1]));
   
$_SERVER['PHP_AUTH_USER'] = strip_tags($name);
   
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}

//set http auth headers for apache+php-cgi work around if variable gets renamed by apache
if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) {
    list(
$name, $password) = explode(':', base64_decode($matches[1]));
   
$_SERVER['PHP_AUTH_USER'] = strip_tags($name);
   
$_SERVER['PHP_AUTH_PW'] = strip_tags($password);
}
?>

<< Back to user notes page

To Top