我正在向我的 PHP/Apache 服务器发送 Ajax 请求。该请求包含一个 Authorization
header ,如下面我的浏览器开发工具的屏幕截图所示:
当针对我的本地 Apache 服务器进行测试时,我可以使用 apache_request_headers()
从 PHP 访问 Authorization
header 。 .但是,在我的生产服务器上(在共享 Linux 主机上)从 apache_request_headers
返回的数组中缺少 header ,如下所示:
array(10) {
["Cookie"] => string(31) "_ga=GA1.2.1071821587.1446317606"
["Accept-Language"] => string(14) "en-US,en;q=0.8"
["Accept-Encoding"] => string(19) "gzip, deflate, sdch"
["Referer"] => string(27) "http://goaunited.com/admin/"
["User-Agent"] => string(110) "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"
["Accept"] => string(33) "application/json, text/plain, */*"
["Cache-Control"] => string(8) "no-cache"
["Pragma"] => string(8) "no-cache"
["Connection"] => string(5) "close"
["Host"] => string(13) "goaunited.com"
}
为什么 Authorization
header 不包含在我的生产服务器上的 apache_request_headers()
响应中?什么可能导致它被省略?
最佳答案
经过一些快速搜索发现设置重写规则有效
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
谁能告诉我它是做什么的?
关于php - “授权” header 与请求一起发送,但在 apache_request_headers() 中丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34472303/