Installing WordPress Multisite with different domains

I own a few domains: IIVQ.net (this has always been the host for my e-mail-domain), citrastructurae.net and it’s brother xn--citrastructur-ggb.net (see) and urbanandrural.net. I made a few posts on citrastructuræ, but wanted to keep that page for it’s subject while also writing about the tinkerings I do, mainly to serve as a memory to myself so I know what the hell I did 2 years ago setting up that raspberry pi or kodi system. IIVQ.net pointed to the citrastructurae.net page, but I wanted it to contain it’s own blog.

Because I have chosen the cheapest package at my webhost antagonist.nl, I can’t install multiple wordpress blogs, nor do I really want to. Enter wordpress multisite (I recommend you read that and Before you create a network thoroughly before going on). However, I have found the installation non-trivial.

There basically is the old (using WordPress Mu Domain mapping plugin) and new way (native to WordPress 4.5 and higher, but some say even native to WP3.0) to do this, and most sites don’t explicitly mention which way they used. However, my findings are that the two don’t mix. My advice: stay clear of all explanations that mention Mu Domain mapping and/or Sunrise.

Even for the new, native way, there are two possible methods: semiautomatic and manual. Both come down to the same, but I have found the manual way to be less work. The semiautomatic way is explained on WordPress’ multisite installation manual under steps 1 to 4. Basically they entail your wordpress site telling you what to do in the manual way.

The manual way is explained in many sites. I used the one from my webhost, Antagonist, which has an explanation in Dutch which is basically the same as what the semiautomatic install tells you to do. Both don’t work out of the box for my site setup.

My site and WordPress setup

My domain package was bought at antagonist.nl, years ago, with the domain urbanandrural.net. The domain IIVQ.net that I always had had my e-mail on, had been held hostage for four months by a bankrupt previous hoster, so I felt it was better to keep that into my own (i.e. Namecheap’s) hands, and let it point to a new website. Antagonist didn’t sell websites without a domain, so I chose the domain urbanandrural.net with it.

When I started citrastructuræ.net, I installed wordpress via Antagonists hosting manager, Direct Admin, into a subdirectory of urbanandrural.net, so I could temporarily set up an “under construction” holding page. This means my wordpress installation is in ~/public_html/citrastructurae/ and not, as I suspect most sites are, in the root ~/public_html/. The wordpress installation however, thinks it lives on citrastructurae.net, not on urbanandrural.net.

What I wanted from the multisite setup

What I wanted is called a subdomain setup. This is meant for subdomains like site1.example.com and site2.example.com, but can also be used for multiple real domains (not-subdomains) like site1.com and site2.com, which is what I want.

The opposite is a subdirectory setup, which has sites like example.com/site1 and example.com/site2.

Installing Multisite

All the red text in the code examples will have a further explanation to it, blue is what you have to change for your own settings.

wp_config.php

In ~/public_html/citrastructurae/wp_config.php, just above the line that says

/* That's all, stop editing! Happy blogging. */

add

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
$base = '/';
define('DOMAIN_CURRENT_SITE', 'citrastructurae.net');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('WP_ALLOW_MULTISITE', true);
define('COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );

The red line comes from Cleanteam. Without it, I found that I could not log in to any of my wordpress sites (I got a “wrong password”, and 3 then 1 attempts left) and only with hassle to my WordPress Dashboard (log in, get a “wrong password”, go to request new password, then instantly be in the dasboard. But on going to a site, you had to log in again, and there the request password trick didn’t work).
However, don’t copy it from Cleanteam’s site but retype it, because the his examle uses the wrong quotes: «‘» and «’» instead of «’».

Also, a very important tip from objectiv: Clear your Cookies.

.htaccess

Most manuals (including the WordPress semiautomatic setup) then ask you to put the following lines in your .htaccess file:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

For me this was an unclarity, as I have two relevant .htaccess files: the one at ~/public_html/ and ~/public_html/citrastructurae/ and none seemed to work. I found out that, because I have installed the wordpress in a subdirectory, I need to change two RewriteRule lines of ~/public_html/.htaccess with the $1 in it into

RewriteRule ^(wp-(content|admin|includes).*) citrastructurae/$1 [L]
RewriteRule ^(.*\.php)$ citrastructurae/$1 [L]

In ~/public_html/citrastructurae/.htaccess, I removed everything, as it is inherited from the root .htaccess.

Domain installation

The next step(s) are to set up your domains in your host, and if applicable, you registar. I had already done these.
They are different from host to host, but you need to point your “other” domains to your “main” domain as an alias in your hosting package.

This is in my webhost’s Directadmin, under Domain pointers

And if you haven’t done so and have domains via someone else than your website host: add the A records in your registar’s package. This will be different for each host and registar.

The view from Namecheap’s manage Host Records sites.

WordPress installation

After you have gone trough the steps above and cleared your cookies, login to your WordPress and create a new site (via My Sites → Network Admin → Sites → click Add New), with a bogus subdomain name:

Then, in the list of sites, click to edit the newly create site, and change the site address into the full domain that you want:

Now, you should have a new, albeit empty, blog.
To test this, go to both sites (old and new) and log in to both, log out a few times, and change from site to site using My sites → [any site from the list] without getting a login box. And try to add a new page and see if it works – on one of my attempts, it wouldn’t save anything.

Internationalized domain names

I have citrastructuræ.net (note æ, not ae – also known as xn--citrastructur-ggb.net). By the above setup, it is an alias to my multisite, but has no site set up. It then goes to the user registration page for citrastructurae.net, which is worse than going to an error page.
As a stopgap, I added, per John P Bloch’s suggestion,

define( 'NOBLOGREDIRECT', 'http://citrastructurae.net' );

to my wp_config.php. It is not the best solution (in the old single-site setup, sites would keep their internationalized domain name in the root) but for now it works.

Join the Conversation

2 Comments

  1. Dear, Thank you so much! I had the same problem and followed every step. It worked!!!!

Leave a comment

Leave a Reply to kevin Vonk Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.