We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40735
    • 119 Posts
    Hi!
    I have it in my head that contexts can be used to manage multiple domains from a single codebase. Is this correct? I have three domains and subdomain or two and I'd like to serve them all from a single Revo installation. If this is something MODx can do, where can I find information on how to get this set up?
    Thanks!

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 3109 ☆ A M B ☆
      • 894 Posts
      Yes, MODX can handle this with contexts for each site make sure you install ContextRouter it will make your life much easier when hosting multiple sites with MODX.

      Here are 2 tutorials that do it the manual way.

      Top Level Domain

      Sub Domain

      If you use ContextRouter you can avoid almost all of these steps.

      Good Luck.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 40735
        • 119 Posts
        Thanks! I'll check this stuff out.
        • discuss.answer
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          It involves contexts, a gateway plugin and htaccess rules (or equivalent). Here's one recent tutorial on doing this. http://www.gelstudios.co.uk/blog/articles/2013/modx-revolution-multiple-top-level-domains-from-a-single-install.html
            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
            • 40735
            • 119 Posts
            So I'm finally getting around to trying this out but I'm having some problems. I created the subdomain in cPanel and pointed it to a subdirectory immediately under the web root. I then followed the steps here: http://www.belafontecode.com/how-to-host-multiple-sub-domains-on-modx-revolution/. I created the context and set up the keys like so: http://img42.com/FIFKC. When I got to the "Now We Make It Tick" section, I instead installed ContextRouter. The documentation for this extra says that all it needs is a properly set up context and it's plug-n-play but it didn't seem to do anything. Should I have pointed the subdomain at the web root instead of it's own directory?

            After failing with ContextRouter I uninstalled it, leaving it on the server for future reinstall in case I figure out how to use it, and I completed the steps in the original tutorial. Now I'm getting a 503 error. The tutorial mentions that this could be the case if I have the path to the core wrong or if my context settings are incorrect but I can't see a problem with either of those.

            Core path:
            [email protected] [~/public_html/core]# pwd
            /home/ravenfli/public_html/core
            


            config.core.php:
            define('MODX_CORE_PATH', '/home/ravenfli/public_html/core/');
            define('MODX_CONFIG_KEY', 'config');


            Anyone know what I might be doing wrong?
            Thanks! [ed. note: dwillis210 last edited this post 13 years, 4 months ago.]
              • 28042 ☆ A M B ☆
              • 24,524 Posts
                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
                • 40735
                • 119 Posts
                That worked! Thanks!

                I'm curious about why it worked though. ContextRouter is still uninstalled and I removed the rewrite rules from my .htaccess file before I updated the subdomain to point to the web root. The context that I created is still there with the same keys but that alone isn't enough to make it work, is it? So what IS making it work? I'm running 2.2.7.
                  • 3109 ☆ A M B ☆
                  • 894 Posts
                  Dave when using ContextRouter all you need is to create a few context settings, mainly:

                  • http_host
                  • site_start
                  • site_url

                  These are the most important ones, I recommend you also create context settings for:

                  • site_name
                  • error_page
                  • http_host_aliases
                  • base_url

                  In order to get ContextRouter working properly with your sites.

                  Once you do this you will see how much easier it is than the manual method you are trying to use right now which will cause a lot of issues with extras that are not coded to handle multiple contexts and have tons or url rewrite issues.

                  Also make sure you get rid of all the stuff you did manually otherwise it might cause issues with ContextRouter.

                  I hope that helps, good luck.
                    Benjamin Marte
                    Interactive Media Developer
                    Follow Me on Twitter | Visit my site | Learn MODX
                    • 40735
                    • 119 Posts
                    That's just the thing though. I undid the manual steps I had taken so I could give ContextRouter another try after updating my subdomain but it just started working. ContextRouter is not installed. All I have is the context itself with the settings you suggest. I'm glad it's working but I'm not clear about WHY it's working.
                      • 3109 ☆ A M B ☆
                      • 894 Posts
                      With ContextRouter you just need to point the domain to the MODX install and MODX takes care of the rest, with the manual mode you need to create a folder for all of the config files for the new site and also create those settings as well so it knows where to go.

                      Hope that makes sense.
                        Benjamin Marte
                        Interactive Media Developer
                        Follow Me on Twitter | Visit my site | Learn MODX