We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 45778
    • 75 Posts
    I've been trying to solve this one for much longer than I care to admit. I have four contexts. Apache points them all to the same folder on the web server, and I'm using a plugin (same code as here: http://rtfm.modx.com/revolution/2.x/administering-your-site/contexts/using-one-gateway-plugin-to-manage-multiple-domains) to process the different domains. I also tried using the Gateway Manager plugin, but currently have that one turned off. Both plugins successfully point the different requests to the correct start pages for each context.

    The start pages work just fine in all of the context. But the only context that processes friendly URLs correctly for all of the interior pages is the web context.

    For all of the other contexts, the links on the respective start page are constructed correctly, such as http://mysite.com/folder/page. The links look like they should work. But when I click on them, I'm given an Apache 404 error (not MODx 404 error).

    If I manually type in something like mysite.com/index.php?q=test ("test" is the alias of one of the pages), the request works, and I see the page, but the address bar says mysite.com/index.php?q=test. It should say mysite.com/test.

    If I type mysite.com/index.php?id=724, which is the same test page, the URL renders as mysite.comtest/ which doesn't work at all.

    If I type the alias of a page that is not on the top level of the context -- a page that is within a folder -- using the q convention (such as mysite.com/index.php?q=level2, where "level2" is the alias of a page within a folder), I am given a 503 error: page not found. This appears to be a MODx error, because there is no Apache footer at the bottom of the message.

    If I turn off friendly urls completely for either the context or for the whole system, the pages in all of the contexts render correctly, the links work, and everything seems to be fine, except that I don't have friendly URLs.

    My .htaccess file consists of these lines of functional code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

    In my template, I'm using a hard-coded base url: <base href="http://mysite.com">

    In my context settings for the contexts that aren't working, I specify the following:

    http_host: mysite.com
    site_start: 689
    site_url: http://mysite.com
    base_url: /
    error_page: 650
    unauthorized_page: 651

    It seems like I must be missing something relatively simple, but I can't figure out what it is. Why would the friendly URLs work only in the web context and nowhere else?

    This question has been answered by paulbohman. See the first response.

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      As far as I know, most of the gateway plugins require additions to the .htaccess file. I prefer to use this method (without the .htaccess modifications) and the plugin mentioned in the comments to the article - no need for any .htaccess modifications:

      http://www.multilingual-modx.com/blog/2011/seo-friendly-multilingual-websites-with-modx-and-babel.html
      https://gist.github.com/gadamiak/3812853
        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
        • 45778
        • 75 Posts
        Thank you for the reply. It looks like that solution is for contexts that are subfolders. I have separate domains, so I don't think those solutions are appropriate.

        And yes, it seems to me that additional changes need to be made to the .htaccess file, but I can't find any instructions that tell me what needs to be done. If anyone can point me to some instructions, that would be very helpful.

        It would also be really helpful if someone could add that information to these pages in the documentation:
        http://rtfm.modx.com/revolution/2.x/administering-your-site/contexts/using-one-gateway-plugin-to-manage-multiple-domains
        and
        http://rtfm.modx.com/extras/revo/gatewaymanager

        Because the instructions right now appear to leave out some critical information.

        In the meantime, though, somebody must have written the technique down somewhere, right? Please point me in the right direction, if you can.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Perhaps this will help; it's an older article using subdomains rather than subdirectories http://www.multilingual-modx.com/blog/2011/multilingual-websites-with-modx-and-babel.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
            • 45778
            • 75 Posts
            The problem that I'm trying to solve is friendly URLs on the other contexts. I didn't see that addressed in the other tutorial. My contexts are working, but only if I turn off friendly URLs on all of the contexts that aren't the "web" context. I described the situation as thoroughly as I could in my first post, hoping that might provide a clue to someone who has done this before. Any thoughts?
              • 3749
              • 24,544 Posts
              Do you have this tag in the head section of all templates:

              <base href="[[!++site_url]]" />


              (The exclamation point is important.)


              And do you have a site_url Context Setting for all contexts?
                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
                • 45778
                • 75 Posts
                I don't use that notation, but I do hard code the different base urls in each of the corresponding templates, so they should go to the correct location, and which should be the equivalent of the MODx code you wrote above.
                  • 45778
                  • 75 Posts
                  Just to be sure, I tried setting the base url in the template using [[!++site_url]], but that didn't change anything.

                  The links are being constructed correctly. When I view the source code, they point to the right friendly url places. And the base url is set correctly in the template. When I click on the link, the address bar even has the correct web address. But for whatever reason, I get an Apache 404 error. Not a MODx 404 error. It's an Apache error. That leads me to believe that I need to add something else to the .htaccess file, but what would I add? The friendly URLs are already working perfectly on the default "web" context, and they seem to be working perfectly on the other contexts, right up until I get the Apache 404 error.
                  • discuss.answer
                    • 45778
                    • 75 Posts
                    Ok, the solution turned out to be super simple, as I thought it might. The server administrator had enabled AllowOverride All for one of the domains, but not for any of the others, so they were ignoring the .htaccess file.

                    Since I'm not the server admin, I didn't have access to that setting, so I couldn't see that it hadn't been enabled. Sigh.

                    Well, that was a lot of work over such a simple oversight. Thanks to those who provided ideas and suggestions.