Search code examples
phpwordpress.htaccesscorsadmin-ajax

Cross-Origin Request Blocked. Wordpress Plugin Not Working


We have a Wordpress website, hosted by GoDaddy. Before we went "live" we had it located at staging.coiski.com (wordpress was installed in a folder called /staging), and then when we went "live" we moved it to coiski.com using the following instructions:

askwpgirl.com/move-wordpress-from-subdirectory-to-root-directory

In the process of the move, everything worked except our WPB Filterable Portfolio plugin on the coiski.com/work page. Specifically, none of our lightboxes are working, and we are getting the following message:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://staging.coiski.com/wp-admin/admin-ajax.php. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘http://coiski.com, *’).

Here's what we've tried, to no avail:

Adding the following code to our .htaccess file:

<FilesMatch "\.(php)$"> 
 <IfModule mod_headers.c> 
 Header set Access-Control-Allow-Origin "*" 
 </IfModule> 
</FilesMatch>

Adding the following code to our header.php file:

header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Methods: GET, POST');

Any other ideas what we could try? Any help would be greatly appreciated.


Solution

  • It look likes your WP is still setup to http://staging.coiski.com domain.

    You can change it in MySQL database - table named {wpdb prefix}_options with option name siteurl and home

    Or you can enforce it in yours wp-config.php by these consts:

    define('WP_HOME','http://example.com');
    define('WP_SITEURL','http://example.com');
    

    You can read about it here: https://codex.wordpress.org/Changing_The_Site_URL#Edit_wp-config.php