We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47401
    • 295 Posts
    Hi

    Ive been trying for the past few days now to try and setup 1 context with 2 domains. I have tryed gatwaymanager which isnt working for v2.3.1 yet. ive tried contextrouter which doesnt really seem to do anything, so I guess that this isnt working either.

    can anybody refer me to anything that i may have not tried yet? or anything else I could try?

    what im trying to do is:
    ensure that 2 domains can access the same modx database/content
    the apache is setup correctly for both domains which point to the same instance.

    I need to incorporate google href lang, for me to do this, this requires the site to have:

    2 domains to access the same area
    2 lines in the head need to be added to the header of the website, but each line showing the same page name (friendly urls)

    <link rel="alternate" hreflang="x-default" href="http://www.domain1.com/page-name-1.html">
    <link rel="alternate" hreflang="en-gb" href="http://www.domain2.co.uk/page-name-1.html">

    on all pages, the page name will change pending what the page the user is on.

    google analytics code also need to change depending on what domain the user comes in on, if the user comes in on domain1.com then google analytics code is xxxxxxxxxxx, if user comes in on domain2.co.uk then yyyyyyyyyyy will be shown.

    also the footer needs to change depending on what domain is selected, so for example if the user comes in on domain1.com then the footer shows an image, if the user comes in on domain2.co.uk then the text is converted to text and footer is slightly changed.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      If your DNS and/or web server configuration is pointing both domains to the same instance of MODX, you could use snippets to modify output based on the MODX_HTTP_HOST ( [[++http_host]] ) value, which gets calculated in the config.inc.php file on every page request.

      You would need a snippet to provide the alternate URL, and one to provide alternate content. Using naming conventions for chunks, such as domain1.com_footer and domain2.co.ul_footer, for the alternate content would simplify automating the loading of the appropriate chunk depending on the [[++http_host]] value.

      You don't need any gateway managers or anything like that; what they do is switch contexts depending on the request's domain.
        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
        • 3749
        • 24,544 Posts
        @Susan: If the host is pointing both domains to the MODX root, will the HTTP_HOST value be different?
        If so, wouldn't there be potential $_SESSION issues?

        BTW, not everyone will agree, but I think you're wise to avoid contexts here.



          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting