Change headers for one custom PHP file

I have a server.php file that I wish to host on the same server as my Wordpress site, that is required to send a POST me

I have a server.php file that I wish to host on the same server as my Wordpress site, that is required to send a POST message with a header of Content-type: application/json.

Wordpress is preventing me to use <?php header("ContentType : application/json"); ?> and doing so, it redirects to some file on https://site/wp-json/, which is not what I want.

Tried using the below code in the same file, but then it returns HTTP 500 Internal server error:

function changeHeaders($headers) {

    $headers['Content-Type'] = 'application/json';
    return $headers; 
}

add_filter('wp_headers', 'changeHeaders');

How do I change the headers just for that file without the need to create a subdomain or host it on another server without Wordpress?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745482168a4629606.html

相关推荐

  • Change headers for one custom PHP file

    I have a server.php file that I wish to host on the same server as my Wordpress site, that is required to send a POST me

    2小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信