【发布时间】:2016-12-23 01:25:39
【问题描述】:
在我的cake PHP3 REST API 中检查请求标头Authorization。但我无法访问它
$auth = $this->request->header('Authorization');
因为$auth 的值为空。
我正在使用 apache 服务器并将下面的内容添加到 .htaccess 作为文档。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
如何获取标头授权值。示例值如下。
Authorization: Basic YW50b24ubHVuZGJlcmdAY29kZWJ1aWxkZXJzLnNlOkNiMTMxMDI0ISE=
【问题讨论】:
标签: php .htaccess rest cakephp cakephp-3.0