Support » Plugin: WordPress MU Domain Mapping » Howto: Domain Mapping without a Plugin – Instructions

  • 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.com will 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/

Viewing 15 replies - 1 through 15 (of 46 total)
  • Plugin Author Ron Rennick

    (@wpmuguru)

    @cleanteam – thanks for the detailed instructions. I’ve made it a sticky thread 🙂

    Hi @cleanteam

    As far as I understood your solution will have the side effect of the mapped site not being available anymore via the subdomain or does it?

    @ron – welcome 🙂

    @bjornw – that’s correct, the subdomain ceases to exist as an uri.

    @cleanteam, Thanks.

    rothschild86

    (@rothschild86)

    Here’s a variation on above with additional constraints:

    – no dedicated ip
    – no more addon domains can be added in cPanel. Will used parked domains instead and rewrite root path with htaccess (http://stackoverflow.com/questions/5623179/change-the-document-root-of-a-parked-domain)

    Here it goes (sorry if it is too terse):

    Variables
    Parked-domain.com
    Multisite-dir/ subdir where multisite is installed

    – Have multisite ready and wordpress subsite in question set as a subdomain
    – create a wildcard subdomain in cPanel (ex. * pointing to Multisite-dir/)
    – Create a parked domain cPanel
    – Point Parked-domain.com’s nameservers to your host
    – Go to My Sites > Network Admin > Sites>Edit
    – Set SiteUrl to read parked-domain.com/multisite-dir/
    – Set Home to read parked-domain.con
    – Edit wp-config.php in multisite-dir – add define( ‘COOKIE_DOMAIN’, $_SERVER[ ‘HTTP_HOST’ ] );
    – Edit ROOT .htaccess in cPanel as follows
    – Clear browser cookies if something is not working

    RewriteRule ^parked-directory – [L]
    RewriteCond %{HTTP_HOST} ^(www\.)?parked-domain\.com$ [NC]
    RewriteRule ^(.*)$ parked-directory/$1 [L]

    Plugin Author Ron Rennick

    (@wpmuguru)

    @rothchild86 – this is a sticky post. Please create a new thread.

    nyckidd

    (@nyckidd)

    So in a nutshell if i map this out succesfully then my domain for example abc.com which has the multisite at abc.com/site2 will be accessed via xyz.com ? ill then the permalinks also change ie from abc.com/site2/permalink-structure to xyz.com/permailnk-structure ?

    my multisite is on a sub directory u so will be using @rothchild86 option

    cleanteam

    (@cleanteam)

    @rothschild86 thanks for the rewrites. have already used parked domains in certain conditions (e.g. ssl per mapped domain) and the multisite picks them up nicely in a separate install, but good to know there is a solution for the given restrictions too 😉

    @nyckidd I am sure to read in @rothschild86 instruction

    – Have multisite ready and wordpress subsite in question set as a subdomain

    . As for your permalink question – they should be fine, but in any case backup your install before any attempt!!!

    This worked like a charm, just one bit of info to clarify.

    When you write to add

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

    to wp-config – do you mean *exactly* that – or should I be replacing those various texts (i.e., COOKIE_DOMAIN with values for the servers I am using?

    This is not clear to me.

    I know this is likely an elementary question but I hope the answer helps others who might come along later as well.

    @mikelbyl good question. that line is used as-is. php/wp will do its thing behind the scenes to replace the placeholder.

    Perfect – thank you.

    Wanted to share with you guys my experience in overcoming a couple of concerns I had with this setup:

    1. I like using www. in front of my domains.
    2. I wanted to prove this could be done without a static IP address for the multisite.
    3. I wanted to give my clients the easiest possible instructions for modifying their domain registration, and avoid having to maintain A records in the event of a static IP address change (if using a static IP address for multisite).

    Amazon Route 53 gave me the path to do this. In your AWS console:

    1. In Route 53: Create a hosted zone for the client’s registered domain (foosite.com) with a www CNAME record pointing to your multisite (www.mymultisite.com).

    2. In S3 Bucket: Set up an S3 bucket for the (non-www) client’s foosite.com and statically map that to www.foosite.com.

    3. In Route 53: In the new hosted zone, create an A record for the (non-www) foosite.com and specify it as an Alias, pointing it to the bucket created in step 2. This assures that both www.foosite.com and foosite.com will end up pointing to www.mymultisite.com.

    Now, back in your multisite dashboard you can make the network site URL be www.foosite.com; it will work.

    Give your clients the DNS names that AWS Route 53 assigns in the hosted zone, and that’s all they need to do — use those DNS names and don’t even worry about modifying A or CNAME records.

    Imagine having a few hundred clients and one day your static IP address changes — it would be like herding cats to get them to go into registrar and make the A record mapping update (!) This solves that dilemma.

    To take this to the next level, you can also set up “white label” DNS with AWS, so you can tell your clients just use dns.mymultisite.com or whatever you wish to call them. It’s a very slick solution.

    A note for CPANEL: some hosting companies don’t allow the wildcard incoming subdomain to map. You can also use an add-on domain or a parked domain (foosite.com), and point that to public_html or wherever you have WP installed. This effectively creates a virtual host record in Apache config, for the incoming mapped site.

    McPace

    (@mcpace)

    I’ve followed the sticky post while attempting this on a subsite setup. I’m getting a redirect loop error on the site I’m trying to map.

    Has anyone else gotten this to work with a subsite setup vs a sub domain setup? My server admin did have a question on where to point the apache docroot? Shoud it point to the root of the wordpress directory (base install)?

    Thanks for this post. I followed these steps and can see my site from the interweb – echn-usa-iah.org.

    However, the site is not showing up o=in the WP Control Panel under My Sites. I can see it under Network Admin/Sites and the original properties.

    I tried to login to the Control Panel directly at echn-usa-iah.org/wp-admin but the usual credentials I use for the Multisite dashboard don’t work. I am getting an error saying:

    “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress”

    But I can log into the multisite dashboard with the same credentials just fine at wrrs.uga.edu/wp-admin.

    Any idea what I am missing here. I am running WP 4.6 – just updated about a month ago.

    Thanks,
    WildOnion

    I never got the non plugin version working, but installing the plugin and using the sunrise.php file got mine working. My main install was running on https so the mapped domain’s wp-admin was blocked until I installed a cert on the mapped domain. Now all is running smooth. So maybe my experience with subsites and not using the plugin was due to not having ssl setup yet? Wish I could’ve confirmed this working with a sub site setup, but now I’m a fan of just installing the plugin.

Viewing 15 replies - 1 through 15 (of 46 total)
  • You must be logged in to reply to this topic.