dongsun5330 2016-05-11 09:41
浏览 230

启用Apache http授权标头

I write an API with PHP ZF2 they use HTTP Authorization. I fetch all HTTP Headers with apache_request_headers() (also tested with ZF2's $this->getRequest()->getHeaders()).

It works on my locale installed version. But on my server the HTTP Authorization Header are not available. My Browser Debug tool show me that the Authorization header properly send.

Both server are running with the same software: Ubuntu 14.04 with Apache2 (Server version: Apache/2.4.7 (Ubuntu)).

Enabled apache2 modules (auth_basic is enabled): enabled Apache2 modules

Is there a PHP ini setting to allow Authorization header?

edit 2015-05-13:

$headers = apache_request_headers();
if (isset($headers['Authorization'])) {
    echo 'you are auth';
} else {
    echo 'there is no Authorization';
}

On my locale system this returns 'you are auth', on the server 'there is no Authorization'. Tested with Postman app in Chrome browser.

edit 2015-05-14: I think it is an Apache2 topic.

How can i enable the Authorization header in Apache2?

  • 写回答

1条回答 默认 最新

  • douxuanwei1980 2016-05-14 09:02
    关注
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    

    in the .htaccess solves the problem.

    But i do not know why this is not necessary on my locale system.

    评论

报告相同问题?

悬赏问题

  • ¥15 flink cdc无法实时同步mysql数据
  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名