We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 727
    • 502 Posts
    I can access my site from:

    http://www.foo.com


    and:

    https://www.bar.com/~foo


    I also want to use friendly URLs. However in the default friendly URL directives in the .htaccess file there is only one RewriteBase entry:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    


    The [(base_url)] reflects the RewriteBase setting. My problem is that I need to be able to ensure that [(base_url)] is correct for both URLs. I.e. it is either "/" or "/~foo/". How can I achieve this? Any ideas?

    Andy
      • 33372
      • 1,611 Posts
      Well, if the second case will only be used for SSL, there are lots of ways that you could separate out those two in .htaccess. I find that I always have to play around until I get it right, however. Check the Apache docs or search for .htaccess tricks.

      You should be able to use
      RewriteCond %{SERVER_PORT} 443
      and
      RewriteCond %{SERVER_PORT} 80

      or set up a Virtual Host for each.
        "Things are not what they appear to be; nor are they otherwise." - Buddha

        "Well, gee, Buddha - that wasn't very helpful..." - ZAP

        Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
        • 727
        • 502 Posts
        Thanks Zap, that did the trick! Previously I tried using {HTTPS} !=on etc. but it didn’t work.

        I now have just about all the pieces in place to allow selective encryption of MODx pages, based on a TV checkbox. I’ll clean it up and post it as a How To when I have finished it.

        Andy
          • 33372
          • 1,611 Posts
          Oooooh! That would be a VERY nice trick indeed! I have been setting some pages for ShopX to https only in .htaccess, but it would be so much more user-freindly if it could be set via a TV (or by choosing a specific template).
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn't very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 727
            • 502 Posts
            Should have it finished in the next day or so. Only problem left is to ensure that a form on an encrypted page is POSTed using encryption, and I think I have an easy solution for that.

            Andy
              • 33372
              • 1,611 Posts
              That shouldn’t be a problem, since MODx writes its URLs relatively anyway...
                "Things are not what they appear to be; nor are they otherwise." - Buddha

                "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                • 727
                • 502 Posts
                Yep, I found that out pretty quickly. Based on your suggestion I’m also going to allow template based encryption without the need for a TV, so you can choose which you want to use. Anyway, I now have it working just fine on a test site using a shared SSL certificate. smiley

                Andy
                  • 33372
                  • 1,611 Posts
                  That’s excellent! It will be useful for a lot of different purposes, including ShopX, login screens, etc. I suggested using a template instead of a TV as the trigger because I tend to have an SSL template with an https base href and other specific SSL files (mostly to avoid partially-encrypted pages; I used to add Google Analytics SSL code in those also, but now the plugin can recognize that the page is SSL and add the correct links).
                    "Things are not what they appear to be; nor are they otherwise." - Buddha

                    "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                    Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                    • 727
                    • 502 Posts