We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    I have a strange issue occurring on a site.
    We have a valid https certificate.
    In the system settings i have:
    server_protocol    1
    


    (I also tried https instead of 1 with the same result.)
    On most pages, the site looks fine, but occasionally I visit a page, and the CSS isn't loading - and upon inspecting the source code, the site_url is displaying as http://www.domain.com instead of https:www.domain.com

    It seems to be random - I can visit out pages, and they are fine - it also seems to get resolved when I clear the cache.

    I cannot work out what on earth could cause the site_url to be displayed differently on some pages and not others?


    Presumably it's some sort of caching issue??


    Any one have any ideas?

    Thanks
    Andy
      • 53161
      • 130 Posts
      Are you on shared hosting? Sometimes they need to set up settings for SSL or whatever.
        • 51020
        • 670 Posts
        Quote from: stefany at Sep 11, 2018, 02:54 PM
        Are you on shared hosting? Sometimes they need to set up settings for SSL or whatever.

        Thanks Stefany,

        I have my own VPS, and the certificate is installed directly on there by me.
        All my other sites have certs and they are OK - just this one being a pain!

          • 38783
          • 571 Posts
          Do you have <base href="[[!++site_url]]" /> (uncached) in the header of all of the templates for the site?
            If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

            email: [email protected] | website: https://andytough.com
            • 51020
            • 670 Posts
            Quote from: andytough at Sep 11, 2018, 04:12 PM
            Do you have <base href="[[!++site_url]]"> (uncached) in the header of all of the templates for the site?

            yes I do - it's uncached, which is why I'm so confused!
              • 38783
              • 571 Posts
              Do any of the templates (assuming you have more than one) have CSS files accessed via a relative path? I have had problems with this before.

              Instead I tend to use the site_url here as well, although I don't call it uncached

              <link rel="stylesheet" href="[[++site_url]]assets/theme/css/style.css">
                If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

                email: [email protected] | website: https://andytough.com
                • 51020
                • 670 Posts
                Quote from: andytough at Sep 11, 2018, 04:19 PM
                Do any of the templates (assuming you have more than one) have CSS files accessed via a relative path? I have had problems with this before.

                Instead I tend to use the site_url here as well, although I don't call it uncached

                <link rel="stylesheet" href="[[++site_url]]assets/theme/css/style.css">

                Thanks for this.

                The css is called in a heder chunk, which is used by all templates - which is strange why it's only certain pages.
                I have tried that anyway - but the problem is that it thinks the base url should be http rather than https - so it still doesn't load the css file.

                It's the fact that the base url is being output as http instead of https which is causing the issue - If I manually use the domain name in the base href, then it all works fine - but I would prefer it was generated by Modx, rather than hard coded.
                  • 49407
                  • 159 Posts
                  Are you on a proxy connection, or is your host on a proxy, or is the server caching somewhere else (outside of modx)?

                  I had some issues with cache settings before, that's why I ask. Any caching happening between your connection to the internet and your modx installation can cause some issues like this. I found that this is a huge issue working from libraries on wifi.
                    • 51020
                    • 670 Posts
                    Quote from: aaronkent at Sep 11, 2018, 05:32 PM
                    Are you on a proxy connection, or is your host on a proxy, or is the server caching somewhere else (outside of modx)?

                    I had some issues with cache settings before, that's why I ask. Any caching happening between your connection to the internet and your modx installation can cause some issues like this. I found that this is a huge issue working from libraries on wifi.

                    I’m not sure of the answer to that one!
                    I don’t think any caching happens outside of mods though. It’s a standard cloud vps running on whm and cPanel.

                      • 3749
                      • 24,544 Posts
                      The server_protocol setting should definitely be set to https. Try setting that and manually deleting all files in the core/cache directory.

                      If that doesn't do it, I'd add a rewrite rule to .htaccess to always convert http to https.
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting