We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7327
    • 195 Posts
    Hey guys,

    I'm wondering if a MODX installation on a webhost configured with 2 domains (1 aliasing another) will work without a hitch? This is the scenario I'm facing right now:

    domainname-1.com (Primary Domain, configured with webhost)
    domainname-2.com (Alias, points to domainname-1.com's webhost)

    Visitors accessing domainname-2.com will see what domainname-1.com's contents but retains domainname-2.com in the URL address bar. Do I need to do anything to MODX to make it work properly in this setup? In other words, I just need the two domains to access a single MODX installation. Anyone faced this scenario before?

    Cheers,
    Les
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Yes; it works just fine. All you need is to set up your DNS records appropriately.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 7327
        • 195 Posts
        Hmm.. so it works, I just have a small problem. Since I ran the install script via domainname-1.com (I'm thinking this has something to do with it), going to domainname-2.com and viewing the site is no problem, however, since I used [~#~] in my chunks, the generated links are still domainname-1.com. Is there anyway to change this based on alias so that if users visited domainname-2.com, links generated still refer to that?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          So if a visitor comes in on domain1.com all links should say this, while if they come in on domain2.com all links should say that?
          [ed. note: sottwell last edited this post 14 years, 7 months ago.]
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 7327
            • 195 Posts
            Yep, that's the idea.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              It should do that by itself; I've had to do some .htaccess fiddling to get it to stop doing it!
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                It is probably due to caching; try having the Wayfinder snippet uncached (although that will slow the site down it shouldn't be enough to notice)
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 7327
                  • 195 Posts
                  Hmm.. how strange lol! I also didn't activate the part in the default .htaccess file about automatically adding in the www since I thought that would make the domain name in the URL fixed to a specific value.
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    If the page is requested from domain1.com and is cached, then of course all the (cached) links will be with domain1.com, no matter how the page is subsequently requested. If the domain will be variable, then anything that generates URLs will have to be uncached. This would include Wayfinder and Ditto.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 7327
                      • 195 Posts
                      Hmm... good point. So I need to uncache to make this work? But this'll mean sacrificing performance, right?