A frequently used practice in MODX is to use a base href tag in templates. This makes creating portable sites, re-usable baseline starting points/Snapshots, and moving from stage to production much more straightforward. It’s also critical for success with MODX’s friendly URL method.
However, if you cache these types of URLs, things can not work as expected, resulting in “broken green bar” websites when implementing SSL and browser security warnings, or Search Engines indexing the wrong URL.
MODX Cloud allows a site to be accessed by multiple URLs in addition to your custom domain name:
- cNNN.paasX.YYY.modxcloud.com as the internal cloud URL
- project.account.modxcloud.com as your own project URL that’s more personalized and memorable
- example.com is a custom domain
To prevent SSL-related browser warnings, and to ensure Search Engines and your Visitors see the correct site URL, add the following base href tags in your MODX website HTML <head> section above any other things that have relative URLs (e.g., CSS or local JS):
<base href="//[[!++http_host]][[++base_url]]">
System setting variables (anything with a "++" token) are stored in memory in MODX. Therefore there is no performance penalty for calling them uncached. Many sites use a cached site_url setting, which results in broken behavior when changing URLs during a site launch.