We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46039
    • 76 Posts
    I am going to test this issue thoroughly, however I now think this is the root cause: https://github.com/modxcms/revolution/issues/6034

    Something smelled familiar when looking through the repo issues, and I'm frankly shocked it was closed with little serious discussion.

    Please skip down to this post to see the issue in a very simple context:

    https://forums.modx.com/thread/101921/https-access-to-a-http-site-builds-absolute-https-links-for-internal-resource-links-and-caches-them-is-this-a-known-issue#dis-post-549533

    I am working on a MODX 2.3.3 site trying to solve a very odd issue assumed to be with the internal URL creation.

    I have a reference to the site_url uncached for the base href. If I access the site via HTTPS the site_url shows as https, pretty much expected.

    The issue is if someone accidentally accesses the site via HTTPS, MODX seems to cache some of the relative links as https; meaning there is a situation where the site is being accessed via HTTP, but some of the internal links on the page are absolute https, and following them results in cert warnings. Basically, an erroneous https link to the site can cause other users to be served https pages.

    This doesn't affect wayfinder links, presumably because they are all uncached?

    Is this a configuration issue? Are resource links supposed to be cached? Any idea on how to rectify this easily?

    IF this is an internal link building issue, would setting the default scheme (link_tag_scheme) to 0 be the solution? Are there any downsides to this besides locking down the site to http only?

    Any other theories on causes would also be welcome. Investigating it has proven nearly impossible. One thing to note is that I have had reports that some people arrive on the site via the address bar, first time visitors, and also get served via https, which might contradict the URL scheme theory.

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

    [ed. note: johnnyp last edited this post 7 years, 1 month ago.]
      • 17301
      • 932 Posts
      What do you have in your .htacess file? If you have an SSL certificate then wouldn't it make sense to force HTTPS anyway?
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 46039
        • 76 Posts
        Quote from: lkfranklin at Mar 20, 2017, 04:00 PM
        What do you have in your .htacess file? If you have an SSL certificate then wouldn't it make sense to force HTTPS anyway?

        Apache simply rewrites to http://site.com

        There is no SSL for general site access, and no interest in using it. I have informed client of SEO gain, user friendliness etc, but understandably they feel they don't need it.
          • 17301
          • 932 Posts
          Fair enough - try adding this to your htaccess

          RewriteCond %{SERVER_PORT} 443
          RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]


          If it doesnt work please post up your htaccess file (omit the domain)
            ■ email: [email protected] | ■ website: https://alienbuild.uk

            The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
            • 46039
            • 76 Posts
            Rewriting doesn't change the fact the page gets served via https.

            htaccess is simply rewriting all subdomains to http://site.com and also handling FURLs.

            I feel this issue is definitely with the way MODX is building the URLs. If I invert the issue by requesting via HTTPS and view the cached links, they DONT have https, so they are not relative to the base href or site url. [ed. note: johnnyp last edited this post 7 years, 1 month ago.]
              • 46039
              • 76 Posts
              This makes less and less sense the more I look into it.

              I can now see a vanilla home resource link [[~1]] with scheme -1 (set in config) with HTTPS:// while the site_url returns HTTP:// on the same page...

              I've attached a screenshot of the base url (site_url, uncached) and the href of [[~1]] to show that I'm not making this up (I know the issue sounds borderline stupid).

              [ed. note: johnnyp last edited this post 7 years, 1 month ago.]
                • 3749
                • 24,544 Posts
                Do you have a rule in .htaccess that converts the protocol to https?

                This is one way:

                RewriteCond %{SERVER_PORT} !^443
                RewriteRule (.*) https://yoursite.com/$1 [R=301,L]
                  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
                  • 46039
                  • 76 Posts
                  Hey Bob,

                  No, the htaccess file has no https specific rules. Nothing on the site is using https except some third party resources.
                    • 17301
                    • 932 Posts
                    What do you have in system settings for server_protocol?
                    Do you have multi contexts on the site?
                    Or any extras like redirectoid or anything else that could be writing the rule?
                      ■ email: [email protected] | ■ website: https://alienbuild.uk

                      The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
                      • 46039
                      • 76 Posts
                      http server protocol, no extra contexts, and no special extras.