Domain Mapping without a Plugin

Yes, it works natively without instructions, and here is what you need to know to make it work:

recent versions (as of WP 4.x) of WordPress Multisite (fresh installs) have the ability to map your custom domain (e.g. example.com) onto a subsite of your install without the help of a plugin. This should be possible with subdomains and subdirectory type sites ( I have accomplished this with subdomain and not tried with subdirectory myself, so someone may want to confirm this actually works.)

But it somehow remained a “hidden feature” – i.e. there is no proper UI – and there is a definite lack of comprehensive information on the web. Hence I am typing this short guide on how to get this accomplished.

What you don’t need: – a plugin or sunrise.php

What you need: – you need a dedicated IP Address for your multisite install (ask your hosting provider to set it up for you, if you are on shared hosting). You can add other sites and installations in your account if you want, but you can have only one multisite install per IP!

The guide is given assuming you have CPANEL access. I keep this short and to the point as I don’t have time for an elaborate explanation. sorry.

Here we go:

Step 1: Create a Multisite install – obviously (instructions are abundantly available on the net, hence I refrain from explaining this step).

Step 2: if you want to use subdomains, create a wildcard subdomain (just create a subdomain with an asterisk ‘*’ (no quotation marks) as subdomain name in your CPANEL.

Step 3: create a subsite that you wish to map your custom domain on.

Step 4: Login as network admin and go to My Sites > Network Admin > Sites and choose ‘edit’ for the subsite you have just created.

Step 5: in the info Tab enter the new custom domain (e.g. example.com) in the Site Address (URL) field. Don’t use the www, but insert the domain as http://example.com and click “save changes”.

Step 6: in your registrar’s DNS settings you have to create an ‘A’ record pointing to the IP adress of your multisite install. (You can create one for ‘example.com’ and one for ‘*.example.com’ so the http://www.example.comwill be taken care of).

Step 7: this last step is important. While the domain will now resolve to your subsite, you need to add one line of code to your wp-config.php to correct an issue with cookies. As cookies are currently set for subsite.maindomain.com, you won’t be able to even login from example.com. Add the following line of code to wp-config.php after all the multisite parts to have your site hand out cookies for example.com:

define( ‘COOKIE_DOMAIN’, $_SERVER[ ‘HTTP_HOST’ ] );

That’s all – you have just created a subsite with your own custom domain!

https://wordpress.org/plugins/wordpress-mu-domain-mapping/

 

Copied from https://wordpress.org/support/topic/howto-domain-mapping-without-a-plugin-instructions/

Leave a Reply

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