18

I want to work with WordPress multisite, but I want to be able to use my own names. For example my main site is called example.com. If I want to add a new site to my multisite network it's gonna be called newsite.example.com. I want it to be newsite.com without example. Is there a way to achieve this?

I heard about domain mapping with a plugin, but I dont know if this is relevant to this question. If it is relevant I would like to know what exactly this is.

  • May be worth noting that to do with without a plugin you'll have to have a Dedicated IP, at least that has been my understanding. – Neal Jones Feb 10 '17 at 16:52
23

There seems to always be a bit on confusion on this topic. Perhaps WordPress could do a better job guiding it's users in this process. Although, I suppose Multi-site wasn't intended to be used for TLD's.

So first of all, I would install WordPress, setup multisite, and configure it as a subdomain network configuration.

Here's a sample configuration for your wp-config.php file in the base directory of your WordPress installation:

/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
define( 'DOMAIN_CURRENT_SITE', 'www.primary-domain.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Then, here's the basic configuration for your .htaccess file as a subdomain configuration, in the base directory of your WordPress installation:

# BoF WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [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]

# EoF WordPress

Now in order to get TLD's to work properly, I've had to make some additional configurations to the wp-config.php file like this:

define( 'COOKIE_DOMAIN', '' );
define( 'ADMIN_COOKIE_PATH', '/' );
define( 'COOKIEPATH', '/' );
define( 'SITECOOKIEPATH', '/' );

That's it with the WordPress specific configurations.

Personally, I like to have one Apache Virtual Host for the primary domain in the network and then configure that virtual host with alias domains. Each alias domain being one of the additional sites in your network.

However you end up tweaking your setup, you need each domain's DNS to resolve to the same web server, and each domain to be pointed to the same directory the primary domain is installed with WordPress. Each domain in your network needs to point to the same web server with DNS records and share the same directory path for the files used by WordPress.

Once you've got everything configured and setup properly as discussed above. Log into your WordPress administration area and navigate to the Network administration area to add a new site into your network.

When you go to add a site, it will enforce you to add the website as if it were a sub domain under your primary domain. Just roll with it. Enter something temporary.

Once the site has been added, then go find it under the list of sites in your network. Click edit on that specific site. Now, you can fully 100% change the domain name of that website. That's when you would put the actual domain name for this TLD site.

I know it's a bit of trickery to do it that way, but it works and you don't need to use any plugins.

  • Thanks for this, seems to work - and it did seem to need the cookie part. For me, I 1) registered a new domain, 2) pointed its nameservers toward my existing WordPress Multisite host, 3) in cPanel, did an Add-On Domain, setting the document root as the same public_html as the primary site (like you said; I didn't try it the default way, of a new directory, so not sure if that would work), and 4) changed the subsite url from oldsubdomain.primarysite.com to newdomain.com Fingers crossed, no DNS issues so far. – Robert Andrews Oct 6 '18 at 20:39
  • I love this answer...yet I have an issue. Your suggestion for changing the .htaccess, as the wordpress also gave the same modification. when I do this change, the system crashes. Any ideas of why that would be? – Debbie Kurth Jun 26 at 2:07
4

It is possible without any plugin since some releases ago (can't remember the concrete release but the feature has been there for a while now). However, if you start from scratch, you should install WordPress multisite in the subdomain mode.

You have to declare a main URL (probably kevin123.com) as the main URL for the network (multisite). This is stored in wp-config.php in the DOMAIN_CURRENT_SITE constant and the site (formerly known as »blog«) using this domain as home URL must have the ID stored in BLOG_ID_CURRENT_SITE. But this is pretty much default stuff during the standard installation process.

WordPress allows you only to specify the sub-domain, when you create a new site. But after the site is created you can edit it and add a completely arbitrary value for the site URL. I described it some time ago in this answer with some screenshots: Are nested subdomains possible with a subdomain multisite?

You might also need to set the constant COOKIE_DOMAN to an empty value in your wp-config.php:

define( 'COOKIE_DOMAIN', '' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.