I had this question posted here, maybe admins did not understand it correctly and marked it as duplicate, so I am posting it again, because I cannot access these variables as defined here. And so called duplicate question does not help me with my query. In my case when I call PHP_AUTH_USER
, PHP_AUTH_PW
, and AUTH_TYPE
they are empty, null
. Can someone please help me understand why? My .htaccess file:
AuthType Basic
AuthName "You need to login to access this page."
AuthUserFile /usr/local/..../.htpasswd
Require valid-user
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
When I do var_dump($_SERVER);
in my PHP code, I see that none of these variables are set, why is that? Is it impossible to access these variables if basic HTTP Authentication used with .htaccess and .htpasswd files alone?