如何在Wordpress子域上启用CORS? [英] How to enable CORS on a Wordpress Subdomain?
问题描述
我有一个使用ajax(房间预订系统)的wordpress页面,还有一个指向页面的wordpress子域。
页面的主要部分将不会加载使用子域时。控制台错误是
XMLHttpRequest无法加载http://mysite.co.uk/wp-admin/admin-ajax.php 。原产地http://meetingroom.mysite.co.uk不允许Access-Control-Allow-Origin。
我已尝试为子域启用CORS,但失败。在服务器上的子域文件夹中,我有一个index.php文件,指向房间预订页面。代码如下: -
<?php
$ _GET ['page_id'] = 2250;
define('WP_USE_THEMES',true);
require('../ httpdocs / wp-blog-header.php');
除了Access-Control-Allow-Origin错误,子域的工作非常好。
有人可以帮我修复吗?谢谢!
标题最好从服务器本身发出。所以如果你使用apache你需要告诉apache理想地发送头。
http://enable-cors.org/ server_apache.html
I have a wordpress page using ajax (a room booking system), and also a wordpress subdomain which is pointing to the page.
The main section of the page will not load when using the subdomain. The console error is
XMLHttpRequest cannot load http://mysite.co.uk/wp-admin/admin-ajax.php. Origin http://meetingroom.mysite.co.uk is not allowed by Access-Control-Allow-Origin.
I have tried to enable CORS for the subdomain but failed. In the subdomain folder on the server I have an index.php file to point to the room booking page. The code is as follows:-
<?php
$_GET['page_id']=2250;
define('WP_USE_THEMES', true);
require('../httpdocs/wp-blog-header.php');
The subdomain works very well except for the Access-Control-Allow-Origin error.
Can somebody help me to fix it? Thank you!
headers are best sent out from the server itself. So if you are using apache you'd need to tell apache to send that header ideally.
http://enable-cors.org/server_apache.html
这篇关于如何在Wordpress子域上启用CORS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!