我用到了PHP-JWT(JsonWebToken),這就需要我傳輸token到后台,書寫樣式如下:
header: {
'Accept': 'text/html',
"Authorization": "Bearer "+Token ,
"Content-Type": "application/x-www-form-urlencoded",
}
但是發現在后台獲取不到Authorization,這是因為apache為了安全等方面考慮把它去除了,我們需要修改apache的文件
httpd.conf(一般在 apache/conf下)
1.apache中
<IfModule mod_rewrite.c>
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
#@這下面的語句就是需要添加的語句了
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>
2.如果是phpstudy中的話同樣操作
<IfModule dir_module>
DirectoryIndex index.html index.php index.htm l.php
#@這下面的語句就是需要添加的語句了
SetEnvIf Authorization .+ HTTP_AUTHORIZATION=$0
</IfModule>