Multisite with Static home page mixed with separate domain name

After posting the question, I thought about the process of how htaccess can affect the URL and the results of that request. Then I realized that the new domain is one that would match this statement:

#rewrite to landing
RewriteRule ^$ /landing.php [L]

That would rewrite the domain.com request to domain.com/landing. Which is not what I wanted.

But the entire htaccess file needs to be processed. The next statements – the common WordPress commands – check if the URL’s file or directory exists. If not, then the WP site is loaded.

Since domain.com/landing is mapped to example.com’s root folder, then the landing.php file in that folder exists, so that’s the page that is displayed.

So what is needed is to get the processing of htaccess to the point where the WP commands will execute. Mapping inside WP for that domain.com to a subsite would then take place.

So an htaccess command has to make an exception for domain.com (the subsites’ domain name in that subsite’s Settings). And that is done this way:

#rewrite to landing  except specific domains
RewriteCond %{HTTP_HOST} !^(www\.)?domain.com$
RewriteRule ^$ /landing.php [L]

That condition says “if the request is not domain.com, do the rewrite rule. Since the request is domain.com, the rewrite rule is not executed, so the WP directives can be processed. And we’ll get to the subsite’s content, as intended.

So, if your multisite has these conditions:

  1. Static pages for the main site
  2. Subsites with their own content
  3. A subsite that is set for another domain name (set in the Site Settings by the network superadmin)

Then you need to use the equivalent of this command to get it all to work properly (the “OR” allows for multiple custom domain names for multiple subsites). Note Correction made 14 Apr 2023 for proper syntax.

#rewrite to landing  except specific domains
RewriteCond %{HTTP_HOST} !^(www\.)?domain1.com$  [NC]
RewriteCond %{HTTP_HOST} !^(www\.)?domain2.com$  [NC]
RewriteRule ^$ /landing.php [L]