Using htaccess, godaddy, php, cgi fix, $_SERVER[‘PHP_AUTH_USER’], $_SERVER[‘PHP_AUTH_PW’]
Fixes:
godaddy login keeps on popping up (popup) due to cgi mode.
Works on Specific Categories
See code fix:
1. PHP FILE
$pageurl=$_SERVER[REQUEST_URI];
if(($pageurl=='/categories/x')||($pageurl=='/categories/y')){
if(isset($_SERVER['HTTP_AUTHORIZATION'])) {
$auth_params = explode(":" , base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
$_SERVER['PHP_AUTH_USER'] = $auth_params[0];
unset($auth_params[0]);
$_SERVER['PHP_AUTH_PW'] = implode('',$auth_params);
}
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header("WWW-Authenticate: Basic realm="Private Area"");
header("HTTP/1.0 401 Unauthorized");
print "Sorry - you need valid credentials to be granted access! Try again by refreshing this page. Refresh Pagen";
exit;
} else {
if (($_SERVER['PHP_AUTH_USER'] == 'username') && ($_SERVER['PHP_AUTH_PW'] == 'password')) {
} else {
header("WWW-Authenticate: Basic realm="Private Area2"");
header("HTTP/1.0 401 Unauthorized");
print "Sorry - you need valid credentials to be granted access! Try again by refreshing this page. Refresh Pagen";
exit;
}
}
}
2. HTACCESS (linux)
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]