未使用litespeed设置PHP标头(但可使用apache) [英] PHP headers not set with litespeed (but work with apache)

查看:125
本文介绍了未使用litespeed设置PHP标头(但可使用apache)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的本地开发(无业游民,apache,ubuntu)上,使用PHP标头功能设置Access-Control-Allow-Headers没有问题.

On my local development (vagrant, apache, ubuntu) I have no problem setting Access-Control-Allow-Headers using PHP headers function.

但在生产中,使用CENTOS 6.7的Litespeed. php标头函数将被忽略,并且Access-Control-Allow-Headers始终设置为

But in production, Litespeed on CENTOS 6.7. The php header function is ignored and the Access-Control-Allow-Headers are always set to

X-Accept-Charset,X-Accept,Content-Type.

但是我可以在htaccess文件中设置它们.

But I can set them in the htaccess file.

Header set Access-Control-Allow-Headers Origin, Content-Type, Accept, Authorization, X-Requested-With

PHP标头功能确实可以在

The PHP headers function does work in production for

Access-Control-Allow-Origin "*"

这似乎是服务器配置问题,但我无法确定它的设置位置.

This seems like a server configuration issue but I can't figure out where it is being set.

为什么litespeed会忽略某些标头而不是其他标头的PHP标头功能?

Why would litespeed ignore PHP header function for some headers and not others?

推荐答案

问题是标题中有空格...

The problem was spaces in the headers...

似乎apache和litespeed都以不同的方式对待php标头功能和htaccess的标头设置等等...".

It seems like both apache and litespeed treat php header function and htaccess "header set blah...blah" Differently.

因此您可以设置

X-Accept-Charset,X-Accept,Content-Type,Origin, 

但不是

X-Accept-Charset, X-Accept, Content-Type, Origin

在不同的地方.空格在apache php标头函数中起作用,但在Litespeed中不起作用,而空格在litespeed thaccess的标头集"中起作用,但是在apache中不起作用.

In different places. Spaces work in apache php header function but not Litespeed, and spaces work in litespeed thaccess "header set" but not in apache.

这篇关于未使用litespeed设置PHP标头(但可使用apache)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆