I'm working on a php's function to avoid manual authentication on an intranet application.
I currently use apache_request_headers() to get the headers and $headers['Authorization'] to read the authorization. It was fine on my wamp's server (php 5.5.12 & apache 2.4.9) but not on in prod (PHP Version 5.3.3 & Apache 2.2.15 (CentOS)). I'm on internet explorer 8.
So i need your help : What should i check ? How can i get the apache header Authorization with php on Apache 2.2.15 (CentOS) ?
Most client headers are accessible with $_SERVER['HTTP_xxx']
, for instance, $_SERVER['HTTP_ACCEPT_ENCODING']
. This applies to non-standard headers too and should work with all web servers as opposed to being Apache-dependent like your sample code.
However, the Authorization
header is an exception. PHP decodes that header upon receiving a request and places the username and password respectively in $_SERVER['PHP_AUTH_USER']
and $_SERVER['PHP_AUTH_PW']
.
Put this in your <Directory> or .htaccess:
CGIPassAuth On
https://httpd.apache.org/docs/2.4/en/mod/core.html#cgipassauth
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.