Aliases domains to master site with wordpress multisite installation not correctly redirect

Hi,
For example I have master-site.tv that have the wordpress multisite installation.
Also, I have alias-site.net.
In master-site.tv cPanel I have created the Alias alias-site.net.
After I have change the A value in DNS about alias-site.net with the master-site.tv A value.
Now if I write the alias-site.net url in browser I have this, and it is not what I axpected:
URL: http://master-site.tv/wp-signup.php?new=alias-site.net
and the message is "The site you were looking for, http://alias-sitenet.master-site.tv/, does not exist."

What I expected is that the content and subsite about *.alias-site.net/* are equal same as *.master-site.tv/*

What is wrong in my settings?

  • Adam Czajczyk
    • Support Gorilla

    Hello GiaNet Media

    I hope you're well today and thank you for your question!

    Adding domains to the sub-sites of the Multisite is called "domain mapping" and that can either be done using core WP options only or - if you want some more options, like for example ability to map multiple domains to one sub-sites or a single-sign-on feature - with our Domain Mapping plugin.

    https://premium.wpmudev.org/project/domain-mapping/

    Regardless whether you choose one way or another there a certain pre-requisite settings for the domain. There are two cases: either you are using dedicated IP or not.

    If you are using dedicated IP (so putting an IP address directly in a browser bar opens your multisite) there's no need to add the domain to the cPanel. You'd only need to set A record for the "domain to be mapped" and wait until DNS propagates fully.

    If you are not using dedicated IP, then instead of creating an alias in the cPanel, add that domain to the cPanel as an "add-on" domain and set its "root folder" to the very same path as "root folder" of the main domain of your Multisite installation.

    Once that's set up (either IP or the add-on domain and its root folder) you'll still need to configured that in WordPress.

    If you're not using Domain Mapping plugin:
    - go to "Network Admin -> Sites" and edit the sub-site that you wish to map the domain to;
    - in "Settings" tab replace the address with the one using that new domain

    If you are using Domain Mapping plugin:
    - go to the Dashboard of the sub-site that you wish to map domain to
    - in the "Tools -> Domain Mapping" add up the domain there.

    That being said, this all is in regards to the sub-sites of the Multisite installation.

    However, if you want to use "sub-domains" of the top level domain and want both of them to work at the same time with subsites (so for example *.domain.com and *.other.com are both pointing to the same sub-site of the multisite) yo will want to map sub-domain separately.

    Or, you can use a Multi-Domains plugin but it works a bit differently. Instead of having both *.domain.com and *.other.com pointing to the same sub-site you (or your users) will be able to choose whether the sub-site should be created as a subsite.domain.com or subsite.other.com.

    https://premium.wpmudev.org/project/multi-domains/

    Kind regards,
    Adam

  • GiaNet Media
    • Site Builder, Child of Zeus

    Hi, thanks for your reply.
    So, I need to have this condition "*.domain.com and *.other.com are both pointing to the same sub-site of the multisite".
    Than the Multi-Domains plugin is not what I need.

    So, can you explain me the correct solution to have my condition?

    Thanks

  • Adam Czajczyk
    • Support Gorilla

    Hi GiaNet Media

    Thanks for response.

    I admit I'm still not quite sure if I follow the use case. Let's clarify then (by examples):

    1.
    a) the main domain is "domain.com"
    b) sub-sites are like "site1.domain.com", "site2.domain.com" and so on
    c) the "other.com" is the other domain and
    d) "other.com", "something.other.com", "somethingelse.other.com" etc should all point to "site1.domain.com"

    2.
    a - c ) same as above
    d) "site1.other.com" should equal to "site1.domain.com", "site2.other.com" should equal to "site2.domain.com" and so on

    3) Additionally - the "other.com" should point to "domain.com" or it's not necessary?

    The 1st option would require some "hacky" setup as it's not really supported. The way I see it would be to actually map (either via Domain Mapping plugin or via WP core mapping feature) the "other.com" to "site1.domain.com" but also setup a wild-card for "other.com" and that would require some additional "hack" on WP code level, I'm afraid, to make it work properly.

    The 2nd option is the same as any "domain mapping" with that difference that instead of mapping "top level domain" you are mapping a "sub-domain" - but that can be done with either our Domain Mapping plugin or even a core WP mapping feature.

    The additional 3rd option is not something possible by "default" but there is a chance that it might be doable with some additional code/configuration tweaks.

    To sum it up: is any of these scenarios what you need or is it yet something else? I'm sorry for asking that many questions but I just want to be sure that I fully understand the goal before suggesting any specific solutions. I hope that makes sense :wink:

    Best regards,
    Adam

    • GiaNet Media
      • Site Builder, Child of Zeus

      Hi Adam,
      thanks for the reply.
      What I need to do is the point 2.
      For point 3, yes, it is necessary.

      Than, for the point 2, the first action to do is to install yor plugin "Multi-domains".
      I am waiting for further indications for point 3.

    • GiaNet Media
      • Site Builder, Child of Zeus

      Than, I have installed Multi-Domains plugin to the main site inonda.tv

      I have configured the wp-config.php

      I have inserted all other domains:
      - inonda.net
      - inonda.eu
      - inonda.biz
      - inonda.info
      - inonda.le.it
      All DNS in these sites points to the main site, and there is the A value setted to, for example, *.inonda.net.

      Now, for example, if I write the inonda.net url in browser, the url change to inonda.tv.
      If I write a subsite url, for example webtv.inonda.net the url is redirect to a courtesy page of my hosting and don't open the subsite that exist with url webtv.inonda.tv.
      Why?

  • Adam Czajczyk
    • Support Gorilla

    Hello GiaNet Media

    Thanks for additional explanation and enabling access.

    I think this still needs further clarification but this time from me :slight_smile: Let's start with the "first part".

    You said that the 2nd scenario is what you need. That would be this:

    a) the main domain is "domain.com"
    b) sub-sites are like "site1.domain.com", "site2.domain.com" and so on
    c) the "other.com" is the other domain and
    d) "site1.other.com" should equal to "site1.domain.com", "site2.other.com" should equal to "site2.domain.com" and so on

    You do not need Multi-Domains for it and you actually should not use it for this. You do need Domain Mapping instead. The first thing to do is to set domains right. You said that you have set DNS for all the additional domains to point to your IP and you set wild-card (*.other.com) for them. The question is now whether you do have a dedicated IP or not and if so if that IP does open the main domain of your site.

    I checked it and it does not. That IP is also assigned to 87 domains in total and while I don't know whether these domains are yours or not, it doesn't look like a dedicated IP to me and it certainly is not configured in a required way.

    Therefore, you'd need to go a different way. DNS settings should be fine but itwould be best to add all those additional domains to the server as "add-on domains". If you got cPanel you'd want to use the add-on option there to add them and then:

    1. for each of these domains edit "root folder" and set its value to the same path as the path of your main domain (inonda.tv) is; for example: if your Multisite is installed in "/home/indonda.tv/public_html" folder, that should be the "root folder" set for all of these additional domains (please make sure about the path, I only gave example)

    2. now this might be tricky because it depends on what you server allows and what it doesn't:

    - try creating a wild-card subdomain for each of these additional domains (like *.inonda.net, *.inonda.eu and so on) in Cpanel - that would be the most universal solution
    - make sure that the "root folder" for these sub-domains is also set the same way - if there's an option to set root folder (it should be there) - as in point 1 above.

    Also make sure that any aliases and/or forwardings are removed, there shouldn't be any.

    If this is set correctly, what would should be happening now should be this: which ever of these additional domains or their sub-domains (existing or not yet) you put in a browser, you should be taken to the new site signup page of the main site (under the main inonda.tv domain) or just to the main site (if registration is disabled).

    If that happens, you should now be able to actually "map" domains. So, let's say you got existing site test.inonda.tv and you want it to be also available via test.inonda.net and test.inonda.eu. To do so, you'd go to the dashboard of the "test.inonda.tv" and to the "Tools -> Domain Mapping" page there. There you just add "test.inonda.net" and "test.inonda.eu" as mapped domains.

    This should take care of this part.

    As for the second part - it still won't cause the main site to be available under all these additional domains and nor the Domain Mapping neither the Multi-Domains plugin will not help with this. There's a trick for this that works with regular single installs but I'm honestly not sure if and how it will perform with Multisite and, what's even more important, if it will or not break the mapping (explained above).

    The trick is to add following lines to the "wp-config.php" file (above the /* That's all, stop editing */ line):

    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);

    In Multisite, though, there's more to be changed and if I was about to even try it, I would also change already existing line in the "wp-config.php" to be like this:

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

    It might also be needed to try to set cookies in the other way by adding this to the "wp-config.php":

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

    and - possibly - yet another one (you might need to replace http:// with https://):

    define( 'COOKIEPATH', 'http://' . $_SERVER['HTTP_HOST'] . '/'  );
    define( 'SITECOOKIEPATH', 'http://' .  $_SERVER['HTTP_HOST'] . '/' ) );
    define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );

    That being said, that's "logical" but I have never tried that on Multisite and I'm honestly not sure if this actually will work properly, especially when the mapping (first part) must be also implemented. It's definitely worth a try but I'd strongly recommend at least backing up the current/original "wp-config.php" file so you could undo the changes in case it's either not working or breaking the current setup.

    Kind regards,
    Adam

  • GiaNet Media
    • Site Builder, Child of Zeus

    Sorry for the delay about my reply.
    So, the Domain Mapping plugin and your guide for subsite work fine.
    See the main site webtv.inonda.tv and the other subsite webtv.inonda.net, .eu, .biz, .le.it, .info

    After I have added your code in the wp-config.php and when I write inonda.net in the browser I have this url "http://inonda.net/wp-signup.php?new=inonda.net" and the message "This page don't redirect correctly"...

    What is the issue?

  • Adam Czajczyk
    • Support Gorilla

    Hello GiaNet Media

    I'm glad to hear that the "domain mapping" part works for you.

    As for the 2nd part, the code that I shared is not something that's "official" and I think I should have make it much more clear that it's a "trick" that might, but may also not work. I've seen it used on a regular single WP installs but not on Multisites and I really can't guarantee it to work fine. This, apparently, is and unexpected outcome that unfortunately means, that this will not work. It was worth giving a shot though. In that case, however, it would be best to revert these changes in wp-config then.

    To be perfectly honest with you, I don't know of any reliably working solution for making the main site of the Multisite available under multiple domains, while these same domains are also used for sub-sites and domain mapping. I've just consulted it with one of my colleagues who's also involved in WP core development and he confirmed that this actually seems like a "no go". I'm afraid then that there's no any reasonable way to achieve it and must admit that I don't have any solution for you on this.

    The one possible "workaround" that comes to my mind - though it would be rather "ugly" - would be to try to find such redirect rule for .htaccess that would actually redirect the "domain.com" but not any subdomain of "domain.com" (I'm referring to those additional domains here, not the main install domain) to the main domain, with 302 (temporary) redirect. That might work though the downside is that the user would end-up on an original main domain anyway.

    Best regards,
    Adam

  • Predrag Dubajic
    • Support

    Hi GiaNet Media,

    Domain Mapping and Multi-Domains plugin can work side by side by I'm afraid that they can't be used to accomplish multiple domains on main site.

    Domain Mapping can only be used on subsites to map top-level domain to your subdomain or subfolder site.

    Multi-Domains will allow subsites to have different top-level domains but it doesn't have an option to have different domains for the main site itself.
    For example, let's say that you have subdomain WP network is running on domain.com, and you use Multi-Domains plugin to add two new domains, seconddomain.com and thirddomain.com.
    When you create new subsite now you will be able to choose the top-level domain so your subsite can be sub.domain.com or sub.seconddomain.com or sub.thirddomain.com.
    But this will still not affect the main installation and the domain used there.

    Best regards,
    Predrag

  • Adam Czajczyk
    • Support Gorilla

    Hello GiaNet Media

    I'm really sorry but I'm afraid we don't have solution for this. The "trick" that I suggested to try previously - it can be useful on a regular single WP installs and I've seen it working on such setups. But Multisite is a "different beast" and there are some additional things that come into play. It was worth a try but since it's apparently not working, I'm really not sure if there is anything else that would work that way. Apart from sharing what I know, I have also searched for a solution and also consulted it with some developers but to now luck. WordPress wasn't created with support for such type of usage in mind and, I'm afraid, sometimes there are just no good solutions for some things like that :slight_frown:

    There could be a very "nasty" option to consider but there also are issues with this: loading the site from original domain via HTML frame - a simple HTML page containing HTML frame, put on the additional domain. That's something that was popular years ago but is not considered a "good practice" nowedays, though it could, in theory, do the trick even though it would affect SEO and wouldn't look "nice" (all the pages under the same URL).

    But there's an obstacle in this particular case which is the fact that the same additional domains are also used for sub-sites because because of this such a simple HTML page actually cannot be set as those additional domains point to the Multisite anyway. Perhaps it could be done if such HTML page would be set in a WP root folder as a html file of a name different than "index" and then there'd be a .htaccess redirect to it that would only work if those additional domain names are used. However, I admit I've never tried it and never seen that used so that's a "not sure" option either, I'm afraid.

    Kind regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.