How to Build a WordPress Multisite Network With Multiple Domains

How to Build a WordPress Multisite Network With Multiple Domains

I remember when I first got the idea to build a WordPress network using multiple domains instead of subdomains. It took me countless hours of Googling, trial and error, code hacking and pounding my fists to figure out something which I can now do in just a few minutes.

Even the WordPress website doesn’t give you very clear instructions on how to set up a WordPress network using multisite, and even then you’re stuck using domains like this for your secondary sites:

www.newsite.example.com

www.example.com/newsite

So thought I’d throw out a lifeline in case you’ve trying to figure this out on your own. At the end of this post, I’ll also show you how you can cut the WordPress brand out of the picture and re-brand WordPress for your company name, your logo and links back to your website or start your very own hosting company using WordPress Multisite.

Let’s start with what you’ll need to set up your WordPress network with multiple domains…

Things You’ll Need to Set Up Your WordPress Network

  1. WordPress installed on the domain you wish to be your primary domain.

(I’m assuming you know how to do this ^ already. If not, I suggest getting a hosting company like Hostgator which literally allows you to set up a WordPress site in 30 seconds by clicking a few buttons and inputting some very basic information)

  1. The WordPress Multi  Domains Plugin from WPMU DEV
  2. The Domain Mapping Plugin from WPMU DEV
  3. FTP access to the hosting account where the WordPress network will be set up.
  4. If you’re doing this in a WordPress site which already has content, please back up your database and deactivate your plugins before continuing to step #1.

Step #1: Prepare WordPress for Multisite

The first thing you’ll need to do is go to the directory where your WordPress site is installed and open up your WordPress config file. It carries the name “wp-config.php” as you’ll see in the screen shot below:

 

Open that file and find the copy-paste this code…

define(‘WP_ALLOW_MULTISITE’, true);

…just above the “That’s all, stop editing! Happy blogging” comment, as seen in this example below:

Once that’s done, save your “wp-config.php” file but keep it open because we’ll be editing it again in a moment. Next you go to the WordPress admin area and locate the option on your WordPress admin bar for network setup. As in the graphic below, you’ll find this option under “Tools.”

Once you click that option, you should see a screen where you put in your network name and the admin email and click “install.” If you see a message that asks you to deactivate your plugins first, make sure you do that as instructed at the start of this tutorial.

Once you’ve click the “install” button, you’ll see a screen which has two blocks of code. This is the first one:

**********

define(‘MULTISITE’, true);

define(‘SUBDOMAIN_INSTALL’, false);

$base = ‘/wp/’;

define(‘DOMAIN_CURRENT_SITE’, ‘vqsuccess.com’);

define(‘PATH_CURRENT_SITE’, ‘/wp/’);

define(‘SITE_ID_CURRENT_SITE’, 1);

define(‘BLOG_ID_CURRENT_SITE’, 1);

**********

This code ^ goes in your “wp-config.php” file just under the “define(‘WP_ALLOW_MULTISITE’, true);” code which you’ve already pasted in. So after copying that in, your “wp-config.php” file should look like this:

Once again, save the “wp-config.php” file but leave it open because we’ve got one more thing to do in there.

The next piece of code in your WordPress admin dashboard should look like this:

{code type=php}

RewriteEngine On

RewriteBase /wp/

RewriteRule ^index\.php$ – [L]

# uploaded files

RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin

RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^ – [L]

RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]

RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]

RewriteRule . index.php [L]

{/code }

This code ^ goes into your “htaccess” file which you’ll find under the same directory as your “wp-config.php” file, as in the screenshot below:

The code should replace all other WordPress rules, so after you’ve pasted it into your “htaccess” file, it should look like this:

Once that’s pasted in, save and close the “htaccess” file and log out of your WordPress admin. Then log right back in. When you do, you should be able to open up an option to view your network admin area, as in the screen shot below:

Now you’re ready for the next step…

Step #2: Prepare Your Network for Multiple Domain Handling

Once you’ve got WordPress Multisite setup, your next step is to install the WPMU DEV  Multi Domains Plugin and the WPMU DEV Domain Mapping Plugin . These plugins will allow your users to map secondary installations of WordPress to their own domains. All they’ll need to do is point their DNS towards the IP address where your WordPress network is being hosted.  More on that in a moment.

In order to set up and configure the domain mapping you’ll need to access the plugin options from your network admin dashboard. If you try to access them from the dashboard of the main site or a secondary site, you won’t be able to set it up.

So go to the “Network admin” option in your WordPress dashboard and look under “Settings” for the “domain mapping” option. Once you click that, you’ll come to a screen with some instructions that look like this:

Unfortunately, the instructions on this screen are confusing and inaccurate, and you’ll drive yourself crazy trying to follow them to set up your domain mapping plugin. So let’s lay out exactly what you need to do to finish your installation up.

The first step reads like this:

Please copy the sunrise.php to /home/coach/public_html//wp-content/sunrise.php and uncomment the SUNRISE setting in the /home/coach/public_html/wp-config.php file

The “sunrise.php” isn’t actually under your root folder as it says in these ^ instructions. It’s under the folder for the “domain-mapping” plugin which you’ll find under “wp-content” directory which is in the root directory where your WordPress installation. Move this file into the folder named “wp-content.”

The next step in your WordPress admin dashboard should read like this:

Please uncomment the line //define( ‘SUNRISE’, ‘on’ ); in the /home/coach/public_html/wp-config.php file.

Again, this is a potentially confusing line of code because I’ve yet to see the //define( ‘SUNRISE’, ‘on’ );”  in a “wp-config.php” file. So you’ll need to copy and paste the “define( ‘SUNRISE’, ‘on’ );” without the “//” characters in front of it or the quotations around it. Then, paste this just below the multisite rules which you’ve already pasted into your “wp-config.php” file. Once pasted into your “wp-config.php” file, that code should look like this:

Next, you’ll need to obtain your IP address where your website is hosted from your hosting provider and input that into the place where it requests your IP. DO NOT use YOUR IP for this. It needs to be the IP where your website is hosted, not the IP you log on to the internet with.

The fourth setup option asks if you want non-supporters to be able to set up sites on your network, I’ll leave that up to you.

Finally, you can choose which domain the visitors will be mapped to. I use “domain entered by user” for this option, but again that’s up to you.

Now, your users will be able to set up sites on your network and (provided that their DNS is pointed towards the IP address where your WordPress network is hosted), their sites will map to their own domain.

Bonus Features for Making Your WordPress Network Even Cooler

  1. 1.       Install the WPMU DEV “Ultimate Branding” plugin and change ALL instances of WordPress to YOUR brand name, all WordPress logos and favicons to YOUR brand logo and all links to go back to your main website rather than to WordPress.
  2. 2.       Install WPMU DEV “Pro Sites” to accept payments from your users in exchange for the privilege of setting up their websites on your network.
  3. 3.       Install the WPMU DEV “Multi Database” to have the WordPress sites on your network run off of their own database, thus increasing the performance and scalability of your WP network.

PS: If any of the code in this tutorial does not work, check the single quote character and make sure they’re in plain text format rather than the format which some word processor programs or WYSIWYG editors change them into. The plain text single quote looks more like a small straight line than a curved dash. 

Any questions?

Leave them in the comments section below.

Good luck setting up your WordPress network!

Best,

Seth C