4
我送一個頭服務器下面的請求頭空:授權頭是PHP的var_dump()
Host: xx.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: xx.com
Authorization: Bearer mytoken1234
X-Requested-With: XMLHttpRequest
Connection: keep-alive
在我的PHP文件我想查看與該的var_dump頭()和它顯示以下內容:
["HTTP_ACCEPT"]=>
string(74) "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
["HTTP_ACCEPT_ENCODING"]=>
string(13) "gzip, deflate"
["HTTP_ACCEPT_LANGUAGE"]=>
string(23) "en-US,en;q=0.8,fi;q=0.6"
["HTTP_AUTHORIZATION"]=>
string(0) ""
["HTTP_CACHE_CONTROL"]=>
string(9) "max-age=0"
["HTTP_CONNECTION"]=>
string(10) "keep-alive"
["HTTP_COOKIE"]=>
string(71) "cpsession=scocta5%3aBcbKZGvPoUCv2Yhb%2c2dc8a5c3bd6713b6ab029f16a46980e7"
我嘗試添加以下行到我的.htaccess:
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
或
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
沒有這些設置,授權標頭根本就沒有在var_dump()上顯示,但現在它只是字符串(0)「」。爲什麼我的服務器沒有獲得Authorization標頭內容?
如果你寫的var_dump($ _ SERVER [ 'PHP_AUTH_USER']);的var_dump($ _ SERVER [ 'PHP_AUTH_PW']);在一個PHP文件中輸出是什麼? –
@OfirBaruch都爲空。 – Prosper