PHP headers not set with litespeed (but work with apache)

可紊 提交于 2019-12-09 23:22:05

问题


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

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.

But I can set them in the htaccess file.

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

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.

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


回答1:


The problem was spaces in the headers...

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

So you can set

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

but not

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

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.



来源:https://stackoverflow.com/questions/37502013/php-headers-not-set-with-litespeed-but-work-with-apache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!