How to enable CORS on a cPanel account

There is several ways to enable CORS (Cross-Origin Resource Sharing). On a cPanel server / account you need to do it with htaccess inside the domain's account. You need to edit the htaccess file and add one of these three lines:

This is the riskiest as it allows all domain cross resource sharing:

Header set Access-Control-Allow-Origin "*"

The safest way is to choose the domain to cross share like this:

Header always set Access-Control-Allow-Origin ""

Or you may need to add the mod headers module:

<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin ""

We suggest trying it with the domain and * for testing purposes.

The other ways include adding PHP code in the WordPress functions.php, which we were not able to make work.

And you can add code in the SSL apache core, which we also were not able to make work.

If adding Header always set Access-Control-Allow-Origin "" does not work, it's likely not a CORS issue.

  • cors, server, enable, htaccess, Cross-Origin Resource Sharing
  • 18 Users Found This Useful
Was this answer helpful?

Related Articles

How to flush your DNS cache

Your home computer creates a cache for all DNS settings. It does this to save time each time you...

What is the root login for my new VPS server?

The root login is the same password our system sent you in your welcome email. You just change...

What is the path to PERL?

The path to PERL in PERL script is:#!/usr/local/bin/perl

Do you troubleshoot scripts and apps?

Hello,Sorry, but troubleshooting sripts and apps needs to be done by the scipt maker or a...

How to use PHP-CLI

You would call '/usr/local/bin/php' if you need the php-cli binary, and '/usr/bin/php' if you...

Powered by WHMCompleteSolution