今天遇到在thinkphp框架中獲取不到header頭里邊的 Authorization ,后來在.htaccess里面加多一項解決,記錄下:
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/?s=$1 [QSA,PT,L] #增加如下內容 SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0 </IfModule>
或者下邊這樣
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/?s=$1 [QSA,PT,L] # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] </IfModule> 最后一項解決thinkphp 框架開啟路徑重寫,無法獲取Authorization Header