We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    I had started posting in the Encryption snippet support thread, but the more I think about it, the more I am convinced it’s more of a htaccess subject so I move the details here.

    Here is my problem.

    I have a website (Work in Progress) for which I need to have both http and https pages.

    This website is using both the SEO Strict URLs plugin to avoid duplicate pages and the Encryption snippet to avoid having to switch https for the whole website.

    The Encryption snippet works fine : when I set the TV to "On" the selected pages are served as https (example here) while the unselected ones are served as http (so far, so good).

    One trouble though, if I don’t modify the .htaccess, I have ssl warnings (not good undecided )
    As instructed in the default .htaccess I have uncommented the port 443 conditionnal rewrite rules :

    [tt]# Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
    # https://www.domain.com when your cert only allows https://secure.domain.com
    RewriteCond %{SERVER_PORT} !^443
    RewriteRule (.*) https://www.pargade-notaires.fr/$1 [R=301,L][/tt]

    New problem : if I do so, then the whole website is in https shocked
    It’s strange since the default server port is not 443 and the https rewrite should occur only if SERVER_PORT is 443, or am I mistaken ?
    (FYI, config is in my sig I am running Apache 2.2.8 )

    Now, there is an alternate .htaccess intended to be used with the Encryption snippet :

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

    Which indicates that I am supposed to use different "folders" for http and https...
    Might be a problem, since my intent is to have both http and https pages on the same domain : is that doable or not ?

    One thing I should add also is that I use a workaround to have files served for http and https from the same public_html folder (instead of having secure pages into the private_html folder) : Gildas advised me to create a sym link, which is what I did helped with my server admin :

    [tt]ln -s public_html private_html[/tt]


      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l'outil id
      • 6726
      • 7,075 Posts
      Very cool and thanks grin !
      I’ll try this right now smiley

      It’s worth posting in the repository as an alternative to the Encryption snippet I think smiley

      Quote from: ganeshXL at Mar 21, 2008, 08:07 AM

      OK, I just re-read your post, and also looked more closely at the Encryption snippet. imho, you don’t really need any custom .htaccess rewrite rules at all, if you got all pages in the same folder (no sep. folders for http and https items).

      Just setting the correct URLs at the begin of the snippet should be enough:
      $secureserver = "https://www.mysite.com";
      $unsecureserver = "http://www.mysite.com";

      I did.
      And as I say it works but I get SSL warning, just as it’s explained in the default MODx .htaccess...
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 6726
        • 7,075 Posts
        Ok I understand better, I thought this was "if the requested port is 443 then use the rule below"...

        I uncommented those lines, but if you check the https page, you’ll see you get warnings and this will not re-assure visitors undecided

        Maybe I should revert to a different method if what I need can’t be done (e.g, use a subdomain secure.mydomain.tld for https...)
        But I’ll try your snippet before that...
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 6726
          • 7,075 Posts
          How come I didn’t see that (and why oh why did I put absolute path !) shocked !

          You’re the man grin
          The defineBaseHref snippet works fine along with SEO Strict URLs and the Encryption snippet !

          Very cool, you made my day !!!
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l'outil id
            • 6726
            • 7,075 Posts
            Yeah sorry I already figured it out I should have mentionned it smiley

            Edit : Also I had to call the defineBaseHref cached otherwise it outputs nothing.
              .: COO - Commerce Guys - Community Driven Innovation :.


              MODx est l'outil id