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

    The site (Modx 2.2.5) of one of my clients is now using the https protocol. The SSL certificate has been correctly installed by the host.

    I know that I have to change the htaccess file and I would like to use the MODX 2.6.0 htaccess file which is for the https.

    The changes to be made to the MODX 2.2.5 htaccess file were better indicate than those in the MODX 2.6.0 htaccess file. All I have to do was to change «example-domain-please-change.com» with my domain name.

    My knowledge of regular expressions (regex) is pretty weak and I would not want to make a mistake.

    Could someone more proficient than me in regex complete this part of the htaccess file with the following domain name "mydomain.ca"

    Thanks for your help.


    DOMAIN : mydomaine.ca
    I WANT TO USE THIS OPTION ===> Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
    DID I HAVE TO USE THIS OPTION ==> Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent ...


    # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin 
    #RewriteCond %{HTTP_HOST} .
    #RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
    #RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    #
    # or for the opposite domain.com -> www.domain.com use the following
    # DO NOT USE BOTH
    #
    #RewriteCond %{HTTP_HOST} !^$
    #RewriteCond %{HTTP_HOST} !^www\. [NC]
    #RewriteCond %{HTTP_HOST} (.+)$
    #RewriteRule ^(.*)$ https://www.%1/$1 [R=301,L] .
    
    # 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://example-domain-please-change.com/$1 [R=301,L]
    

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

    • discuss.answer
      • 3749
      • 24,544 Posts
      Uncomment lines 2, 3, and 4 for the www -> non-www change.

      Set the server_protocol System Setting to https to tell MODX you want SSL URLs.


      This step may not be necessary:

      Confirm the https server port with your host (it may not be 443), then Change 16 and 17 to:

      RewriteCond %{SERVER_PORT} !^443
      RewriteRule (.*) https://mydomain.ca/$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
        • 13730
        • 149 Posts
        Thanks a lot for your help
        Everything works perfectly!

          • 3749
          • 24,544 Posts
          Did you have to use the third step?
            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
            • 13730
            • 149 Posts
            No, everything seems to work very well without this third step.
              • 3749
              • 24,544 Posts
              Thanks for reporting back. I wasn't sure if that was necessary or not, though it might speed things up slightly to force the change in .htaccess rather than having MODX do it (or it might not).
                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