Change primary domain wordpress multi site hosting
In this brief turorial we´ll install WordPress Multisite and give each site in the network it´s own separate top level domain.
Changing the DNS settings
First we need to point all the domains we want to use in this network to our WordPress Multisite install. This usually involves two steps:
- Specify the IP address of your server for each domain
- Let your server know it should pass on incoming requests for your domains to your WordPress Multisite install.
In practice this usually means changing the A-records of your domains and point them to your server.
Pick one domain as your primary domain and add it to the server. For the other ones you can create virtual hosts under this primary domain.
In DirectAdmin you would first add a new domain and then go to Admin level > Custom HTTPD Configurations and select your primary domain. You can now add the virtual hosts:
ServerAlias secondarydomain.com www.secondarydomain.com
Install WordPress Multisite
Install WordPress and follow the instructions on how to enable WordPress Multisite .
When asked if you want to use subdomains or subdirectories choose subdomains.
If you installed your primary domain using the www-prefix, a warning will appear when you enable Multisite: We recommend you change your siteurl to example.com before enabling the network feature. Personally I always ignore this warning and have never experienced any problems.
Map your domains
When WordPress Multisite is up and running you can start adding new sites. By default they will use a subdomain like subdomain.example.com. To change this to a top level domain, choose Edit site as Network Admin and specify the domain name you want to use on the info tab.
Also add one more line to your wp-config.php file: define('COOKIE_DOMAIN', '');
To www or not www
If you´re prepending your domains with the www subdomain, you´ll want to redirect the non-www versions of your domain to the www versions. On a single install WordPress takes care of this, but in a Multisite environment I´ve always had to do this manually.
For each domain you´re using, add the below redirect in your .htaccess file (changing example.com to your domain):
RewriteCond % ^example.comRewriteRule (.*) www.example.com/$1 [R=301,L]
You should now have a Multisite install with seperate domain names.