Tutorial: multisite WordPress with multiple domains
If you own multiple WP websites it could be a good choice to host them on the same server within the same WordPress instance. This allows you to install a WordPress theme or plugin once and use it for multiple sites. This helps reducing the maintenance on your site. By default the WordPress multisite (MU) allows you to choose to use subfolders or subdomains for the blogs in your system. The subdomains would make your blogs looks like so http://blog1.yourdomain.com and http://blog2.yourdomain.com. The subfolders would make your blogs look like http://yourdomain.com/blog1 and http://yourdomain.com/blog2. Both options are nice, but not very practical for each situation. Quite often you have sites that have their own domain. In that case, you would want your sites to be accessible by their specific domain names. So http://blog1.com and http://blog2.com. In this article I will present a tutorial on how to setup your server to support multiple external domains within the same WordPress server.
Step 1: setup WordPress in normal way
Just setup WordPress as a single site instance first like you do normally. This step comes down to downloading WordPress from WordPress.org, FTP-ing it to your server and following the wizard until WP is setup correctly.
Step 2: enabling multisite
Perform the following tasks:
Before doing anything ensure you make a backup of all your files, data, personal belongings and your wp-config.php file. We won't take any responsiblity if things go wrong if you follow the steps below.
Adjust the wp-config.php by adding the following line
Login to the admin section of your site (http://yoursite.com/wp-login.php)
Click on Network setup in the Tools section
Follow up the advise to first disabled the plugins
Repeat the step to go to the "network" in the "Tools" section. This time the warning to de-activate the plugins should no longer show up.
Select "sub-directories", and enter the name for your network, and hit "Install"
Follow up the instructions on your screen (that is: edit the wp-config.php in your wp-content folder and edit the .htaccess file and create a "blogs.dir" folder in your "wp-content" folder).
Ensure you are logged off, and login again in the admin section of your WordPress site.
Step 3 - WordPress custom domain for each blog on Multisite
Follow up these instructions:
Download the "domain mapping" plugin zip file from the website from here
Create a mu-plugins folder in wp-content
Copy the "domain_mapping.php" file from the zip file to the "mu-plugins" folder you just created.
Copy the "sunrise.php" file from the zip file in de "wp-content" folder
Edit the "wp-config.php" file and add the line
define( 'SUNRISE', 'on' );
Logout from WordPress
Re-login in the admin part of WordPress
Go to the Network Admin
In the left secion choose "Settings" -> "Domain mapping"
Enter the IP address of your server
Tweak the settings like so:
Remote login: OFF
Permanent redirect: ON
User domain mapping page: ON
Redirect admin pages: OFF
Disable primary domain: OFF
Enter the IP of your server
Step 4 - Add another new site within WordPress and map its domain
Follow up these steps:
Login to the WP backend
Go to the Network Admin in WordPress
From the left menu select Sites -> Add site
Enter the name of your site (this is not the domain, but the sub-directory; the domain mapping occurs later on).
Go to the admin section of the page you just created (so exit the Network Admin)
From the left menu select Tools -> Domain mapping
Enter your domainname, and mark that domain as the primary domain (after you ofcourse ensure the domainname resolves to the IP of your server :)