This is my .htaccess
file:
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Even though I have added below line to my .htaccess
file I cannot access $_SERVER['HTTP_AUTHORIZATION']
.
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
When I'm doing print_r($_SERVER)
I can't find HTTP_AUTHORIZATION
.
I have googled for an answer but none of them worked.
I have previously faced same issue and I solved by adding this line at the top of my .htaccess
that is at the root directory
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
If you're using rewrite rules to pass this header - it may be prefixed by REDIRECT_
Try $_SERVER['REDIRECT_HTTP_AUTHORIZATION']
.
But since 2.0.13 Yii has an abstraction for this, I suggest to use it:
Request::getAuthUser()
to get user.Request::getAuthPassword()
to get password.Request::getAuthCredentials()
to get both.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With