: Why does modx-based site start using different domains for some content? situation I have a modx site on a VPS with multiple domain and subdomain names. The modx site should use what I call
situation
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 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?
More posts by @Sue5673885
2 Comments
Sorted by latest first Latest Oldest Best
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.
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.