WordPress Multisite is a mode in which an unlimited number of sites can run on one installation of the WordPress core, while site domains on the network can be completely different.
When configuring WordPress in Multisite mode, two network options are offered – a network with subdirectories, and a network with subdomains. This option often misleads site owners that all sites on the network will operate exclusively within the same domain, but this is not the case – any site on the Multisite network can have its own domain.
Most often, to work with different domains in the Multisite network, the WordPress MU Domain Mapping plugin is used, which allows you to link one or more domains to any site on the network through a special interface.
This plugin contains its own tables with domains and works through a special file wp-content/sunrise.PHP that is launched at an early stage of loading the WordPress core. In this file, the plugin defines the requested domain and sets the required constants and global variables for correct operation.
Read More: WordPress SMTP Configuration
In newer versions of WordPress core, you can use different domains without additional plugins, based on existing tables with data about each site in the network.
Core Level Domains WordPress Multisite
Today, this method is more of a “gimmick” than a full-blown multisite feature in WordPress. However, kernel developers are very familiar with this method, so using it you can count on full compatibility in future updates.
As with the plugin, this method assumes that you have installed WordPress Multisite in subdomain mode. To set a domain name for a site on the network, just specify it in the site configuration in the network control panel:
Please note that if you are creating a new site on the web, you will first need to create it as a subdomain of the main site, and after that, you can edit it and change it to a full-fledged domain.
After making these changes, the site will immediately start working on the specified new domain (provided that the webserver is configured correctly), but the work is not over. By default, WordPress core stores authentication cookies on the main domain on the network, so for additional domains, a small change is required to the file wp-config.php:
define( 'COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );
After that, make sure that you can sign in to the new domain as well as to all other sites in the Multisite network.
Any additional logic and redirects for additional domains can be written in the sunrise.php file. If you want to have a network with both subdomains and subdirectories, then this is also possible, but not without the additional configuration of the webserver.