We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17883
    • 1,039 Posts
    I have two different domains set up in two contexts (let’s say domainA.com and domainB.com). Everything works fine, but if the client wants to link from domainA.com to domainB.com with [[~id]] (like TinyMCE generates it) MODx delivers a 404. This is somehow expected behaviour, because the alias path cannot be resolved under domainA. (settings: relative paths and base href)

    How to fix this problem? I see two different approaches and like to hear from you which would be the appropriate MODx-way:

    1. Plugin on 404

    We could fire a plugin on 404, take the q parameter and look for matches in other contexts and redirect with 301.

    Advantage: Proper solution which only takes action on 404
    Disadvantage: URLs are not properly rendered in source code (always 404->lookup contexts->301 feels wrong), perhaps Google-issues

    2. Plugin on preRender

    We could identify all [[~id]], look up the contexts and if there is a match in another context with different site_url we just prepend this like: http://domainB.com/[[~id]]

    Advantage: Proper URLs (Google)
    Disadvantage: Performance? Fires on every page load... it also gets only the links which are input properly as [[~id]].

    What do you guys think? Am I overseeing something?
      • 21838
      • 284 Posts
      Isn’t it possible to work with URL full scheme?
      [[~[[*id]] &scheme=`full`]]

      I’d prefer the second option of you but you’re right, it would increase load-time.
        MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)
        • 9849
        • 74 Posts
        Quote from: smooth-graphics at Mar 08, 2011, 03:45 AM

        Isn’t it possible to work with URL full scheme?

        Even if it is possible it does not solve the problem of auto inserted links like TinyMCE does.
          • 17883
          • 1,039 Posts
          Works like a charme with setting site_url and base_url in every context. Sometimes it is so easy...
            • 38360
            • 20 Posts
            Just for those who still struggle with this problem.

            I work with a modx version that started at 2.06 and now is upgraded to 2.2.13.

            I was trying to create a canonical URL to a page in another context

            [[*canonical:!empty=`<link rel="canonical" href="[[~[[*canonical]]? &scheme=`full`]]" />`]]


            The ID of the ressource in that other context is put in the TV canonical...

            I have 8 contexts for some like the web context the URL generation worked for some not. I then right klicked in the tree on each context to edit it and made sure that the permission for the user group (anonymous) was set to 9999, load only.
            This was the case in all the contexts.

            Also I checked that I have set the site_url, base_url and http_host accordingly. All looked good but I still only had it work on some contexts and on others not.

            The solution to this problem was:

            I had to manually delete the (anonymous) entry on the context it self.

            Then I went to the menu "Security -> Access Control" there you have the list with all the users. I selected (anonymous) and set edit.

            There you can globally configure the context settings for anonymous. So I did set the setting for each context again: 9999, load only

            Flushed the permissions and also reset all sessions.

            And it worked.


            I have reason to beleive that by adding the permission on the context caused somehow an error. It can be that this is fixed in new versions, but when you have done it that way and added it a while ago. You might have the same issuee.

            Cheers