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 - 31 through 45 (of 58 total)
  • I don’t know if this happened to anyone else, but my setup wasn’t redirecting from my http to my https site until I added the URL as an addon domain in my host’s domain manager. I was pulling my hair out trying to figure out this issue, so I wanted to post it here in case anyone runs into the same problem. Here’s a video tutorial on how to add an addon domain to your site: https://www.youtube.com/watch?v=KNiXPgcOrrY

    @cleanteam ‘s answer did not work for me either. Using @rleon ‘s answer of

    define('COOKIE_DOMAIN', '');

    Worked for me on WPEngine and allows you to traverse across the dashboards without re-logging in.

    All I did was set my domain name to http://www.example.com (client is using www only) on the subsite and edit the wp-config.php with the above line of code

    Also I am using this great video: https://www.youtube.com/watch?v=Z-2k6lYLVfE to cheat and point my www. with a CNAME to WPEngine and then point the root (@) to www so i can dynamically point the site to WPEngine and not worry about when the IP address changes.

    @wpmuguru PLEASE PLEASE PLEASE can their be a note on the plugin homepage that it does not need to be used anymore and for official instructions on how to get by without it? WPEngine and others still point to using the plugin as mandatory in their support docs.

    And thank you so much for working on all this!!!!

    • This reply was modified 3 years, 11 months ago by jimbtek. Reason: used wrong name instead of @rleon
    • This reply was modified 3 years, 11 months ago by jimbtek.
    • This reply was modified 3 years, 11 months ago by jimbtek.

    I understand how this all works, and would be great to do this without a plugin.

    But for real web developers, I have my site run via Git. I have a Dev branch I edit files on etc. Puch to staging then to master, each deploying to a different location for testing, etc.

    Because my clients create content on the master site, I do a MigrateDB back to staging and dev.

    If I followed the native method, I would have to make an edit for every subsite domain to convert to an alternative to suit dev or staging.

    At the moment I just do not migrate the domain mapping table.

    Is there any way around this at all? I would love to remove the plugin. Less is more.

    For anyone else needing a solution, I have yet to find a solid complete solution, but I did find a compromised workaround.

    When using MigrateDB, just don’t export your main blogs table.

    The only issue with that is that if you add a site under MU, then you will need to add that site to the dev,staging and production manually.

    After that all is good. The Sites under Admin->Sites stays relevant to the server its on.

    Solution for multisite install with differing domains:
    —————————————————————————————-

    I had three sites with the same sub-domain and wanted to add a new site with a different domain here is what I did:

    1. In wp_config.php file, make subdomain = false.

    2. In WP control panel as admin, create a new site. WordPress defaulted to the subdirectory mode so my site initially looked like mainsite.com/newsite. Just save it that way.

    3. Go to My Sites > Network Admin > Sites and choose ‘edit’ for the subsite you have just created.

    4. 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”.

    5. In your registrar’s DNS settings you have to create an ‘A’ record pointing to the IP address of your multisite install.

    6. Add two lines of code to your wp-config.php to correct an issue with cookies:
    define( ‘COOKIE_DOMAIN’, $_SERVER[ ‘HTTP_HOST’ ] );
    define(‘SUNRISE’, ‘on’);

    7. Then add the Administrator as a new user on you new new site.

    8. You should be able to see all subsites in your multisite control panel and be able to login to each site’s control panel separately too as Admin.

    Don’t know if this has already been addressed in the replies, but anyone simply copying and pasting the referenced define function may find that it does not work. That is because this:

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

    is not the same as this:

    define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );

    Check your single quote operators and make sure they’re the right ones. Copy/pasting the second line above may work for you.

    How can I map more than one domain to the sub-site?

    I get 404 error for the admin page and index of/ page for the subsite.com address

    @wanderingonion check the wp-config file

    This line //*define(‘PATH_CURRENT_SITE’, ‘/’); */

    It may have an extra “/” and appear ‘//’. which would cause the unusual admin login behavior.

    This is what caused the login loop for me in the past.

    Creating a subdomain entry in your cPanel or whichever control panel your hosting uses. If it’s cPanel, which is most common, then you should see a Subdomain option:

    Once you are there then add a subdomain that is just “*”:

    Make sure that your document root is the root of your multisite install. Normally that is /public_html/ however, it can differ host to host.

    This solved my problem.

    Hi,

    In our WP multi-site installation we tried a lot of settings which didn’t really work.

    The last we did is the following setup using the method without plugin:

    WP-installation net admin is scansolution.eu and perfectly working. This domain and WP installation is hosted at 1&1 (http://1und1.de).
    It’s also perfectly working with additional domains hosted at 1&1 and directly pointing to WP root directory (like http://etiketten-24.eu/).

    The WP site setup for ‘Etik-24’ (Blogname) is as follows:
    Site Address (URL) (at Info tab): http://etiketten-24.eu/
    Siteurl (at Settings tab): http://etiketten-24.eu
    home (at Settings tab): http://etiketten-24.eu

    Now we need to map a specific subdomain, hosted at one.com, to this installation.

    Therefor we first created a new subdomain tsneu.scansolution.eu at 1&1 pointing to WP root directory.
    Then we setup a new site in Network admin called ‘TS Neuer Test’ (Blogname).

    The WP site setup for ‘TS Neuer Test’ is as follows:
    Site Address (URL) (at Info tab): http://tsn.softvalue.se/
    Siteurl (at Settings tab): http://tsn.softvalue.se
    home (at Settings tab): http://tsn.softvalue.se

    Now we setup DNS in one.com control panel as described in their DNS guide:
    .softvalue.se Web Forward http://tsn.softvalue.se
    tsn.softvalue.se CNAME tsneu.scansolution.eu

    Now when trying to open http://tsn.softvalue.se or http://softvalue.se in browser the following is shown:
    Forbidden
    You don’t have permission to access / on this server.
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    We also testet using http://tsneu.scansolution.eu/ as Site Address (URL) (at Info tab) and http://tsn.softvalue.se as Siteurl and home value (at Settings tab).

    Here we get same result (Forbidden) as mentioned above and the following when trying to open site dashboard:
    Not Found
    The requested URL /wp-admin/ was not found on this server.
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    It would be great to receive your proposal for a correct setup that shows site properly and showing http://tsn.softvalue.se/subdirectory1/… in browser header.

    Many thanks!

    Hi Guys,

    I feel all this is quite confusing … 🙁
    (or maybe it is just me!) so I need a dummy’s guide!

    Ok, so far I have understood that:

    to how to map http://mysite.com to the subdomain http://mysite.mywpmu.com
    with a wpmu installation on a DEDICATED IP
    have been properly described by cleanteam (thanks!)

    —————————————————

    But with a wpmu installation on a SHARED IP
    I run onto a wall!

    Please can anyone, much more clever than me,
    rewrite/correct and complete the following?

    Thanks of your help
    —————————————————

    Mapping mysite.com to a wpmu installation on a SHARED IP

    Step 1: install your wpmu: http://mywpmu.com without www

    Step 2: create a * wildcard subdomain in http://mywpmu.com CPanel

    Step 3: get your domain http://mysite.com (that you wish to map)

    Step 4: create a PARKED (Alias) domain in the http://mywpmu.com CPanel
    called mysite.com

    Step 5: in the http://mysite.com registrar’s DNS settings create
    ????? (CNAME – Url redirect – ….) ?????

    Step 6: in the http://mywpmu.com dashboard create a new site http://mysite.mywpmu.com

    Step 7: in the http://mywpmu.com dashboard go to
    My Sites > Network Admin > Sites and edit the url of
    http://mysite.mywpmu.com
    and change it into
    http://mysite.com

    Step 8: Edit the wp-config.php of the http://mywpmu.com/ and add
    ???? define( ‘COOKIE_DOMAIN’, ???????

    Hi ugondr,

    Many thanks for your description.

    What I need to do is to link sub1.mysite.com from an external provider (one.com) to the WP installation hosted on my provider (1und1.de). So, in one.com CPanel I set a CNAME record for sub1.mysite.com to mywpmu.com

    The site I created in WP MU I set:
    Site Address (URL) (at Info tab): http://sub1.mysite.com/
    Siteurl (at Settings tab): http://sub1.mysite.com
    home (at Settings tab): http://sub1.mysite.com

    I tried this with and without using the Multi-Domain plugin.
    The site always shows 403 forbidden, when trying to open.

    Many thanks

    @cleanteam

    Are these instructions supposed to allow for backend switching between mapped and non-mapped subdomains for super admins? Because that’s not working for me. I can only traverse between subdomains of the same top level domain.

    Also this did not work for me:
    define( 'COOKIE_DOMAIN', $_SERVER[ 'HTTP_HOST' ] );

    But this did:
    define('COOKIE_DOMAIN', '');

    Is there perhaps a way to make it so the backends for all sub sites stay with the non-mapped domain? That would seem to avoid all these issues…

Viewing 15 replies - 31 through 45 (of 58 total)
  • The topic ‘Howto: Domain Mapping without a Plugin – Instructions’ is closed to new replies.