Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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 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?

share|improve this question
    
I would be helpful to know which version of MODx you're using. –  Duncan Lock May 9 '13 at 0:32
    
yes. it says MODX Revolution 2.2.4-pl (advanced) –  naxa May 9 '13 at 4:56
    
I've asked the MODx community on twitter to come have a look. –  Duncan Lock May 9 '13 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? –  Duncan Lock May 9 '13 at 15:21
    
Thanks for your help! I can not reproduce this at will so I can only post details when it occours again. –  naxa May 11 '13 at 17:00
add comment

2 Answers

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.

share|improve this answer
    
thanks, but the Templates already use <base href="[[++site_url]]" />. (I made an edit to reflect this what I maybe should have added earlier) –  naxa May 11 '13 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. –  Mark Hamstra May 23 '13 at 18:35
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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