Multi-Site Subdomain: Show master site under subdomain if no sub site exists

I've got the following situation:

We got a WP Multisite and if a subdomain is not associated to a network site, we want wordpress to show the master site (e.g. blog ID 1) under this subdomain without a redirect.

 www.domain.com -- master site of the multisite network
 existing.domain.com -- shows the existing blog registered under this subdomain
 nonexisting.domain.com -- it should show the same as www.domain.com without any redirects.

I have already changed wordpress to use root-relative URLs everywhere, so it should not matter if we are on www or nonexisting subdomain.

Thanks for your suggestions! :)

Topic network-admin multisite Wordpress

Category Web


You'd need to use a plugin to manage domain aliases like that. Try Mercator by Human Made. Once installed you will see a new tab 'Aliases' when you edit a site in network admin dashboard and you will be able to add and activate domain aliases for a site.

Keep in mind that this is not a good for SEO since it will introduce duplicate content issues (same content on different URLs).

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.