We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42737
    • 16 Posts
    Hi folks, I'm experiencing a strange problem on my modx 2.1.5 site, whereby some pages are cached with a .info TLD instead of the correct .com. The template loads content from the database, however none of the stylesheets or scripts are loaded as they all use relative paths.

    This has happened twice now in as many weeks, and it occurred on a different set of pages than it did last time.

    Now I'm not sure if this is related, but I was experiencing problems with localization of sidebar widgets - depending on what was cached first, the widget would always be in that language. When broken, my template invoked things this way:

    [[$Head]]

    [[Web_Contact_Map]]

    And when I changed it to the below, things started working as expected:

    [[!$Head?]]

    [[!Web_Contact_Map?]]
      • 22303 MODX Staff
      • 10,725 Posts
      In your Head chunk, you likely have something like this...
      <base href="[[++site_url]]">


      You can resolve your cached site_url issue by changing it to...
      <base href="[[!++site_url]]">


      Or you can make sure your site is only accessible from the appropriate domains via your web server configuration.
        • 42737
        • 16 Posts
        Thanks opengeek. It's actually using:

        <base href="http://[[env?variable=SERVER_NAME]]/" />

        ...and I am trying to anticipate why an environment variable was used here instead of just hard-coding the URL. Any idea?

        And I'm pretty comfortable configuring a web server now, but I can't guess what you might be pointing to - what do you propose?

          • 28042 ☆ A M B ☆
          • 24,524 Posts
          The site_url is calculated from the $_SERVER[HTTP-HOST] in the config.inc.php file on each page request. Of course, your page will get cached with the value used for the first request of the page, which is why calling it uncached will get the actual value calculated for that page request.

          I have "parked" domains pointing to my main domain, and sometimes one of the parked domains gets requested. So I have used .htaccess rewrite rules to rewrite anything with those parked domains into my main domain. That way by the time MODx sees the page request, it's been rewritten so all MODx ever gets it my main domain.

          Sometimes web servers are configured in such a way that these $_SERVER values aren't really reliable. You can always set a context setting for the "web" context with the site_url that you want.
            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
            • 42737
            • 16 Posts
            Appreciate the insight. I'm just going to hard code the URL for now smiley
              • 29059
              • 88 Posts
              Quote from: sottwell at Jun 26, 2013, 07:27 PM
              The site_url is calculated from the $_SERVER[HTTP-HOST] in the config.inc.php file on each page request. Of course, your page will get cached with the value used for the first request of the page, which is why calling it uncached will get the actual value calculated for that page request.

              I have "parked" domains pointing to my main domain, and sometimes one of the parked domains gets requested. So I have used .htaccess rewrite rules to rewrite anything with those parked domains into my main domain. That way by the time MODx sees the page request, it's been rewritten so all MODx ever gets it my main domain.

              Sometimes web servers are configured in such a way that these $_SERVER values aren't really reliable. You can always set a context setting for the "web" context with the site_url that you want.

              hi sottwell,

              i, just yesterday, started experiencing this phenomena - where my base href site_url would change to one of our parked/alias domains, & thusly breaking the linked-to font & js libraries. it really concerned me as 1) i don't understand these things, & 2) apparently my host is undergoing a big DDS attack or something. so i was scared i got hacked.

              but from what i'm reading, it's a fairly common thing to have happen. i HAVE double-checked all my config.inc.php files & htaccess - all seems to be in order.

              i will implement the exclamation point to uncache the call & hope that helps. but after reading your post here, i have a couple questions, i f you don't mind...

              1) what would change about a server that would suddenly cause this to happen?

              2) can you share these "htaccess rewrite rules" you speak of please?

              3) and, is it possible to, if i point a different domain i have to a specific directory, to have pages shown from that directory to use this domain in the field of the browsers, then when clicking on a link to a different directory, or even the homepage, switch back to the main domain - all the while sharing the same resources, css/js/etc???
              if so, how? but i suspect you're gonna say 'no'.

              THANKS!!!
                • 29059
                • 88 Posts
                Oops... i may have just done a no-no (SORRY!!!)...

                i found another thread yesterday & replied to it. it's on this same issue...
                https://forums.modx.com/thread/99559/website-with-multiple-domains-same-content-different-logo#dis-post-539731