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

    I have a setup with 2 domains same context. (Why is this the case is another question)
    example.com and example.org
    I wrote a small simpet which detects the version based on $_SERVER['SERVER_NAME'] and loads some aditonal content etc.

    The problem is that if I have a page let's call it 'about', it gets redirected.
    In the context I have set up 'example.com' as http_host

    GET http://example.com/about/ <--- page loads ok with .com specific content.
    GET http://example.com/about <--- gets redirected to 'http://example.com/about/' (with a slash at the end) then page loads ok.

    GET http://example.org/about/ <-- page loads ok with .org specific content
    GET http://example.org/about <-- redirects to http://example.com/about/ (.com domain and slash at the end)

    I am thinking that MODx redirects based on the config not the $_SERVER['SERVER_NAME'] or $_SERVER['HTTP_HOST'].

    So my question is that where in the core this redirect happens because I want to change to use $_SERVER['SERVER_NAME']?

    Thank You.
      • 3749
      • 24,544 Posts
      It happens in core/config/config.inc.php and uses $_SERVER['HTTP_HOST'].

      I'm not convinced that that's your problem, but if it is, I think you would be a lot better off changing your own code to use $_SERVER['HTTP_HOST'] rather than modifying the MODX config file (which might be overwritten in an upgrade).

      Having two separate domains running in one context seems like a really bad idea to me, especially if users will ever go from a page in one domain to a page in the other domain, which would lose all $_SESSION variables (used by lots of extras) and any cookies.

      You might be happier in the long run if you made them separate contexts and put the domain-specific content in Context Settings (or chunks specified in Context Settings).
        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