We have WP multisite network with WooCoomerce shops. All the network is served through Cloudflare CDN.

Our ERP is accessing WooCommerce API of each website in the WP network. Since there so many, calls we are getting 503 from Cloudflare. It's not a server problem. It's a problem of too many requests to Cloudflare.

So what I would like to have is a separated subdomain (example: api.domain.com) for each domain in the network. That subdomain will not be proxied thru Cloudflare.

How to do I do that? How can I add an additional subdomain to a site on WP multisite network?

  • The default Multisite has the option to add infinite domains and site. However, if you mean more networks in the Multisite network, more than one site per network look at this plugin de.wordpress.org/plugins/wp-multi-network
    – bueltge
    Apr 8, 2022 at 5:41
  • We have multisite and I know that it supports indefinite domains. I think you did not understand my problem. I have sites: - domain1.com - domain2.net - domain3.org All those domains are proxied thru cloudflare CDN. To each of this sites I would like to add subdomain API which will not be proxied thru Cloudflare. So if you visit domain1.com or api.domain1.com it should be exactly the same website.
    – grv
    Apr 8, 2022 at 6:10
  • Anyone have idea how to do that?
    – grv
    Apr 13, 2022 at 11:42

1 Answer 1


I have resovled it myself.

I have enabled sunrise in wp-config. Then add a script to sunrise.php to override HTTP_HOST.

I made it dynamic since we have many websites. When you visit api.domainxy.com it automatically shows you domainxy.com.

$re = '/(?:api\.)(.*)/m';
$str = $_SERVER['HTTP_HOST'];

preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);

if ($matches && $matches[0][1] != "") {
  $_SERVER['HTTP_HOST'] = $matches[0][1];
  • 1
    you will probably want to be careful and verify that when not accessing the API itself (when accessing something like the home url) you get redirected to the main site. Another possible gotcha is URLs included in the response. You might want to be sure they point to whatever you expected them to point to (actual page, or another API end point) Apr 21, 2022 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.