I have a modx site on a VPS with multiple domain and subdomain names. The modx site should use what I call the 'primary' domain name's 'primary' subdomain, ie www.intendedname.tld . The problem is that as time pass, the site mysteriously starts using another subdomain for links to content like videos, images, and even pages and (internal) links. The other subdomains doesn't serve this content of course. If I clear the modx cache, the original state is restored. However, the problem comes back again later.

The VPS has a domain registered and multiple A records pointing to the VPS's IP, as subdomains. There is the 'primary' whan which is intended to be used as the public content server, the other ones are like docs. and test., etc.

On top of that, I have dynamic-dns service client installed from no-ip on the machine and a dynamic domain-name bound. It gives a completely different domain name. I originally used it for ssh login and to serve a completely different site.

An nginx server is put into good use to do rewrite the different subdomains to the right places.

edit The modx templates use Templates use <base href="[[++site_url]]" />.

current attempt to fix

The current 'solution' to the problem is to also use the rewrite to rewrite everything to the 'primary' domain and subdomain. In the nginx config file for the site, it utilizes (unsurprisingly) the rewrite directive to rewrite the unexpected server_name entries (ie. the other subdomains) in a server block dedicated to this task.

So with this, the main site basically works (sort of) but this renders all the other functions (docs) useless.

Before this rewrite was set, the 'solution' was to clear the modx cache on a regular basis. The original modx content is not getting corrupted, only the files in cache are.

What can I do to find out what actual the problem is and fix it?

  • I would be helpful to know which version of MODx you're using. May 9, 2013 at 0:32
  • yes. it says MODX Revolution 2.2.4-pl (advanced)
    – n611x007
    May 9, 2013 at 4:56
  • I've asked the MODx community on twitter to come have a look. May 9, 2013 at 15:20
  • Are the links absolute links? Is the source code of the pages exactly the same when they're working and not working? Can you post an example of a not working link and a working one? May 9, 2013 at 15:21
  • Thanks for your help! I can not reproduce this at will so I can only post details when it occours again.
    – n611x007
    May 11, 2013 at 17:00

2 Answers 2


It does sound like a base href problem, like Aaron suggests.

However I would never advise anyone to hardcode it to <base href="http://domain.tld"> - this is a pain if you ever want to copy a site to a staging environment or migrate the site elsewhere.

Instead the simple solution is to have the base href value resolve dynamically and ensure it is not cached: <base href="[[!++site_url]]">. Combine this with a rewrite from domains that should not be used and you should be good.

  • thanks, but the Templates already use <base href="[[++site_url]]" />. (I made an edit to reflect this what I maybe should have added earlier)
    – n611x007
    May 11, 2013 at 16:43
  • 1
    Note the subtle difference between [[!++site_url]] and [[++site_url]] - the latter is cached while the first one is evaluated on every pageview, making sure it doesn't get "stuck" in a subdomain should it be served from that at some point. You should see an improvement by adding the exclamation mark. May 23, 2013 at 18:35

Are you using dynamic base href property in your MODx templates? If so set this to the actual website address you want to be the base href, then clear the MODx cache and you should be all set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.