We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15807
    • 12 Posts
    Hi there,

    I would like to have my site both accessible with http and https. It seems that based on the "Site" -> "Server type" setting it’s either or. Is it not possible to have the links within the site (base href) protocol independent (so if a user connects with http the links are http - and https if he comes along with https).

    Or is there another possibility to achieve this?

    Thanks
    Ki
      • 22303 MODX Staff
      • 10,725 Posts
      By default, the site will be accessible from both, according to your web server configuration details. I’m not sure the server type does anything anymore, but I could be mistaken.
        • 15807
        • 12 Posts
        Hi OpenGeek

        Thanks for your answer!

        Quote from: OpenGeek at Aug 06, 2009, 12:36 PM

        By default, the site will be accessible from both, according to your web server configuration details.

        That’s true. I configured the web server to be accessible from both. But unfortunately MODx sets in every page a ’<base href="http://www.mysite.com/"’. So the first page is encrypted - all following not.

        Can this be changed?

        Thank you and best regards,
        Ki
          • 29774
          • 386 Posts
          Yes you can set basehref dynamically - see the technique I described here:
          http://modxcms.com/forums/index.php/topic,10026.msg216289.html#msg216289
            Snippets: GoogleMap | FileDetails | Related Plugin: SSL
            • 15807
            • 12 Posts
            Hi there,

            Therebechips, thanks for the information.

            Is it possible to change the behavior in general how the variable site_url is built (for [tt]<base href="[(site_url)]" />[/tt])?
            And/or is it vise to delete the [tt]base href[/tt]-Tag from the template completely?

            What I like is that from the users perspective MODx does not change from http to https (or vice versa). So if the user connects with http the links point to http, and if he comes along with https he stays on that.

            Best regards,
            Ki
              • 22303 MODX Staff
              • 10,725 Posts
              As long as you don’t cache the site_url in the base href tag, they should remain on the URL scheme they made the request with. It is not advisable to remove the base tag, as anyone who visits the site with a subfolder will likely not be able to find the CSS or other items linked by relative path from the root of the site (since MODx handles all virtual requests as if they were from the root).
                • 15807
                • 12 Posts
                Thank you for your answer, OpenGeek!

                Quote from: OpenGeek at Aug 10, 2009, 09:47 AM

                As long as you don’t cache the site_url in the base href tag, they should remain on the URL scheme they made the request with.

                That’s it - but how can I do that?
                Unfortunately I can not find the syntax for not caching system settings tags.

                Thank you and best regards,
                Ki
                  • 22303 MODX Staff
                  • 10,725 Posts
                  In Evo, you need to just author a snippet that returns the setting, then you can use the non-cacheable snippet syntax.

                  The snippet, let’s call it SiteUrl:
                  <?php
                  return $modx->config['site_url'];
                  ?>


                  The tag in your content/template:
                  <base href="[!SiteUrl!]"></base>

                    • 15807
                    • 12 Posts
                    Hi OpenGeek

                    Works like a charme! Thanks a lot.

                    Ki
                      • 15807
                      • 12 Posts
                      Hi there,

                      I just made a fresh installation of MODx 1.0.2 on Ubuntu 2008.10 Server - and this snippet doesn’t work anymore... :-(

                      The hostname is returned correctly, but solely with http. I tried $_SERVER[’SERVER_PORT’], $_SERVER["HTTPS"] and even [(server_protocol)] in the template itself. Always with the same result.

                      According the apache access logs, Firefox and a network capture the connection is made with https.

                      Has this been changed in any way since MODx 1.0.0.? What could this be?

                      Thanks in advance
                      Ki