We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46886
    • 1,154 Posts
    I had to hard code this link with https in order to avoid the problem

    This question has been answered by andytough. See the first response.

    • discuss.answer
      • 38783
      • 571 Posts
      I have encountered this problem as well. For portability I use the MODX tag [[++site_url]] instead of hard coding the actual url.

      [[++site_url]]ccc/site.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
        • 46886
        • 1,154 Posts
        Thanks Andy and good point, it does work, but why on earth is this possible. The mystery deepens haha.

        Consider this structure, this is what I started with, I have pulled out unimportant stuff:

        <!DOCTYPE html>
        <head>
        <title>[[*pagetitle]] | [[++site_name]]</title>
        <base href="[[++site_url]]" />
        <meta name="rating" content="General" >

        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">


        <!-- Custom CSS -->
        <link rel="stylesheet" href="css/site_css.css" type="text/css">


        I have told .htaccess to re-write all [[++site_url]] to https.

        Now that second href should be built on the [[++site_url]] automatically, that's sort of what the base_url is for in the first place. Isnt that right?

        When the href does its job its supposed to get the site url in order to finish that request. Or maybe I am way off base.

        Anyway thanks again, its a better way than hard coding.
          • 3749
          • 24,544 Posts
          I would recommend this instead (with the exclamation point). It makes sure the site URL is always fresh and will prevent problems if you ever introduce more front-end contexts:

          <base href="[[!++site_url]]" />
          [ed. note: BobRay last edited this post 5 years, 10 months ago.]
            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
            • 38783
            • 571 Posts
            Quote from: nuan88 at Jun 28, 2018, 01:32 PM

            Now that second href should be built on the [[++site_url]] automatically, that's sort of what the base_url is for in the first place. Isnt that right?

            When the href does its job its supposed to get the site url in order to finish that request. Or maybe I am way off base.

            I agree. I felt I was bodging something that ought to have been working correctly with the code that I had.

            Although interestingly I have just tested reverting my site to use <link rel="stylesheet" href="assets/theme/css/site.css?version=3">, cleared the cache, and it is returning https as expected.

            I do have <base href="[[!++site_url]]" /> on my template as suggested by Bob, so perhaps that is what is making it work.
              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
              • 46886
              • 1,154 Posts
              Thanks for the feedback Andy and BobRay.

              The problem is an interesting one, because it seems to get a pass sometimes and only breaks things after some time. I don't know, sometimes I feel like I have caching problems, like I fixed something the other day and it wasn't fixed the next morning. Annoying.

              But in this case I am 95% sure that bit of code had not been changed recently. It might be something like the browser getting more finicky.