So you’ve gone through setting up WordPress Multisite, and now you’re ready to start setting up new sites in your network. Only trouble is, you want to use unique domains for your sites instead of using subdomains of your main installation. Well, with a little extra effort, it’s entirely possible.
Install the required plugin
There’s an excellent plugin that will do most of the hard work for you. Install the WordPress MU Domain Mapping plugin and Network Activate the plugin.
Before you proceed any further, there’s a couple of things that you have to do manually. Access your site’s installation, either using FTP or your hosting Control Panel and go to wp-content/plugins/wordpress-mu-domain-mapping/ and locate the sunrise.php file. You must move this file up two levels, to the wp-content folder.
Once you’ve done that, find your wp-config.php file and add the following definition. Add it below your previous multisite rules (i.e. above the “Stop editing” line):
define( 'SUNRISE', 'on' );
Move “domain-mapping.php” to the mu-plugins” folder at the wp-content “root” level. This is important as certain web servers won’t render the mapped URLs correctly unless this is done.
Configure the plugin
Now your plugin is correctly installed and when you head to the Network Admin area you’ll notice a menu under Settings called Domain Mapping. Click on that so that you can configure the plugin.
The main thing you need to be concerned with is setting the IP address of your server. To find this, log in to your hosting cPanel and on the main page, you should be able to see the IP address of your server in the information on the left-hand side. If you can’t find the IP address, you can get in touch with your host, or use one of many available free tools to convert the web address to an IP address.
If you fill out the IP address, you can ignore the CNAME field. Then, the remaining options are as follows:
- Remote Login – Means that logging in to one site will log you in to all sites.
- Permanent Redirect – This will create a 301 redirect on your subdomain (as opposed to a temporary 302 redirect) – highly recommended if the domain mapping will be permanent.
- User Domain Mapping Page – Creates a new menu in each site which allows that site’s users to map their own domains (instead of being controlled by the network’s Super Admin only).
- Redirect administration pages – Means that all administration pages will be kept on the original site’s domain, instead of on the mapped domains.
- Disable primary domain check – Means that multiple domains pointing to a single site will be treated as separate sites, instead of redirecting all domains to the noted primary domain (not recommended).
Map domains to your network sites
Now you’re ready to set up the domain for your new sites. You should have already created the site that you’re wanting to map your domain to. At the moment, it will just be a subdomain of your main site – it doesn’t have to be set up or looking perfect – it just has to exist.
Once you’ve purchased your domain, make sure that you set the nameservers for the domain to your hosting account’s nameservers. Then, go to your hosting account cPanel (which all good hosts, including HostGator, should have) and find the Parked Domains option under Domains.
Once in there, add your new domain as a parked domain, making sure that the document root shows as the same folder as your WordPress installation (probably /public_html). If you can’t do this (because you don’t have cPanel for instance), you need to set an A record on your new domain that points to the IP address of your hosting server (which you found out earlier).
Now is the final step. You’ll need to know the “Site ID” of the site you want to map the domain to. If you click on Sites > Sites in the Network Admin, and click on the name of the site (as if to edit it), the URL will include the site ID. It will look something like this (where the Site ID is 2 in the example):
Now back in your Network Admin, go to Domains under the Settings Menu. You’ll see a section for adding a new domain, with three fields: one for the site ID, which you just found out, the domain name and an option whether to set the domain as the primary domain for the site. This is because you can set more than one domain to point to a single site, so you want to specify which one should be the site’s primary domain.
Once you save that, with any luck (and assuming that DNS changes have propagated), if you go to your new domain in a web browser, you should find yourself at your new site.
I’ll grant you that it is a little bit fiddly, and it would be nice if WordPress would bring this into the core and make it a bit more of a fluid process, but once it is set up, you never need to look at it again; the plugin will keep serving up the right site at the right domain.
Did you manage to get through the setup process? Did you encounter any problems? If you need any help getting through this process, you can always ask a question here, or hire me to do it for you.
Content of this part of the blog post was courtesy of : http://www.doitwithwp.com/domain-mapping-for-wordpress-multisite/