thinkphp6下無法獲取header頭中的Authorization(apache版)


今天遇到在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

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM