Php 标头授权在子域上不起作用
我有这个函数用于API的基本授权Php 标头授权在子域上不起作用,php,zend-framework2,Php,Zend Framework2,我有这个函数用于API的基本授权 private function authorize() { $headers = apache_request_headers(); if(isset($headers['Authorization'])){ if ($headers['Authorization'] == '14abd57ece42d9489aeae6e1865064751') { //'akif&&nadeem' re
private function authorize() {
$headers = apache_request_headers();
if(isset($headers['Authorization'])){
if ($headers['Authorization'] == '14abd57ece42d9489aeae6e1865064751') { //'akif&&nadeem'
return true;
}
}
return false;
}
它在我的API域domain.com/API/actionname上运行良好
但当我试图通过子域subdomain.Domain.com/API/actionname访问我的API时,它不起作用[授权失败]
所有代码都正确就位,API在未经授权的情况下运行良好。你知道我该怎么解决这个问题吗
标题的输出如下所示:
array(9) {
["Host"]=>
string(24) "ultimate.bleupage.online"
["Connection"]=>
string(10) "keep-alive"
["User-Agent"]=>
string(115) "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
["Cache-Control"]=>
string(8) "no-cache"
["Postman-Token"]=>
string(36) "6330a309-ffcf-d72e-936a-bf10ff154d45"
["Accept"]=>
string(3) "*/*"
["Accept-Encoding"]=>
string(13) "gzip, deflate"
["Accept-Language"]=>
string(26) "en-GB,en-US;q=0.8,en;q=0.6"
["Cookie"]=>
string(36) "PHPSESSID=p2m0cc7sq7kn8fk2motvrobnn4"
}
尝试使用除
Authorization
之外的其他参数键,如Auth
,因为有时Apache会过滤掉授权头,您可以在此处获得更多信息
您可以访问它,如下所示(使用$\u服务器
):
或者像这样(使用apache\u请求\u头文件):
$_SERVER['HTTP_AUTH']
apache_request_headers()['Auth'];