[英]PHP Authorization header not found
I am working on the codeigniter basic authentication by using Rest_controller. 我正在使用Rest_controller进行codeigniter基本身份验证。 Currently i having the issue on getting anyone of them in the list below from my
$_SERVER
array object. 目前,我在从
$_SERVER
数组对象获取下面列表中的任何一个对象时遇到问题。
PHP_AUTH_USER
PHP_AUTH_PW
HTTP_AUTHORIZATION
HTTP_AUTHENTICATION
Based on my research, the problem is because of the Server API on my server. 根据我的研究,问题是由于服务器上的服务器API引起的。 The Server API of this server is using CGI/FastCGI.
该服务器的服务器API使用CGI / FastCGI。
I even tried add all these to my .htaccess
but none of them is working for me. 我什至尝试将所有这些添加到我的
.htaccess
但是没有一个对我.htaccess
。
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
CGIPassAuth on
Header set Access-Control-Allow-Headers: "Authorization"
The array below is what is get from my $_SERVER
when i try call my api from the postman. 当我尝试从邮递员调用我的api时,下面的数组是从我的
$_SERVER
获得的。
array(52) {
["PATH"]=>
string(28) "/usr/local/bin:/usr/bin:/bin"
["TZ"]=>
string(16) "America/New_York"
["REDIRECT_HANDLER"]=>
string(28) "application/x-httpd-ea-php56"
["REDIRECT_STATUS"]=>
string(3) "200"
["UNIQUE_ID"]=>
string(27) "Wgu-pu3SJZU707d76yB41AAAAAE"
["SCRIPT_URL"]=>
string(24) "/index.php/test_api/test"
["SCRIPT_URI"]=>
string(49) "https://www.river-app.com/index.php/test_api/test"
["HTTPS"]=>
string(2) "on"
["SSL_TLS_SNI"]=>
string(17) "www.river-app.com"
["HTTP_HOST"]=>
string(17) "www.river-app.com"
["HTTP_CONNECTION"]=>
string(10) "keep-alive"
["CONTENT_LENGTH"]=>
string(1) "0"
["HTTP_CACHE_CONTROL"]=>
string(8) "no-cache"
["HTTP_ORIGIN"]=>
string(51) "chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop"
["HTTP_USER_AGENT"]=>
string(121) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
["HTTP_POSTMAN_TOKEN"]=>
string(36) "12be9c43-7d88-3244-b407-ff0a160434ce"
["HTTP_ACCEPT"]=>
string(3) "*/*"
["HTTP_ACCEPT_ENCODING"]=>
string(17) "gzip, deflate, br"
["HTTP_ACCEPT_LANGUAGE"]=>
string(38) "en-US,en;q=0.8,zh-CN;q=0.6,zh-TW;q=0.4"
["HTTP_COOKIE"]=>
string(43) "ci_session=ne4ip07sqkrree86dgmjfackgbn4f4bk"
["HTTP_X_HTTPS"]=>
string(1) "1"
["SERVER_SIGNATURE"]=>
string(0) ""
["SERVER_SOFTWARE"]=>
string(6) "Apache"
["SERVER_NAME"]=>
string(17) "www.river-app.com"
["SERVER_ADDR"]=>
string(14) "67.225.226.183"
["SERVER_PORT"]=>
string(3) "443"
["REMOTE_ADDR"]=>
string(15) "118.200.235.133"
["DOCUMENT_ROOT"]=>
string(26) "/home/riverapp/public_html"
["REQUEST_SCHEME"]=>
string(5) "https"
["CONTEXT_PREFIX"]=>
string(8) "/cgi-sys"
["CONTEXT_DOCUMENT_ROOT"]=>
string(26) "/usr/local/cpanel/cgi-sys/"
["SERVER_ADMIN"]=>
string(23) "webmaster@river-app.com"
["SCRIPT_FILENAME"]=>
string(36) "/home/riverapp/public_html/index.php"
["REMOTE_PORT"]=>
string(5) "60875"
["REDIRECT_URL"]=>
string(24) "/index.php/test_api/test"
["GATEWAY_INTERFACE"]=>
string(7) "CGI/1.1"
["SERVER_PROTOCOL"]=>
string(8) "HTTP/1.1"
["REQUEST_METHOD"]=>
string(4) "POST"
["QUERY_STRING"]=>
string(0) ""
["REQUEST_URI"]=>
string(24) "/index.php/test_api/test"
["SCRIPT_NAME"]=>
string(10) "/index.php"
["PATH_INFO"]=>
string(14) "/test_api/test"
["PATH_TRANSLATED"]=>
string(40) "/home/riverapp/public_html/test_api/test"
["ORIG_PATH_INFO"]=>
string(24) "/index.php/test_api/test"
["ORIG_SCRIPT_NAME"]=>
string(17) "/cgi-sys/ea-php56"
["ORIG_SCRIPT_FILENAME"]=>
string(34) "/usr/local/cpanel/cgi-sys/ea-php56"
["ORIG_PATH_TRANSLATED"]=>
string(50) "/home/riverapp/public_html/index.php/test_api/test"
["PHP_SELF"]=>
string(24) "/index.php/test_api/test"
["REQUEST_TIME_FLOAT"]=>
float(1510719398.04)
["REQUEST_TIME"]=>
int(1510719398)
["argv"]=>
array(0) {
}
["argc"]=>
int(0)
}
What could be the thing causing this issue. 可能是引起此问题的原因。
尝试将此行添加到控制器顶部
header('Content-Type: application/json');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.