We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51020
    • 670 Posts
    Quote from: BobRay at Feb 01, 2018, 01:51 PM
    I looked again and this is what I actually have at my site in .htaccess:


    RewriteCond %{SERVER_PORT} !^443
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
    RewriteRule (.*) https://mysite.com/$1 [R=301,L]



    I'm not sure where lines 2-4 came from or whether they're necessary. mysite.com should be changed to the actual domain.

    Also, make sure you're editing the .htaccess file in the MODX root directory (not the core or manager) and not the ht.access file.

    Be sure the code comes after these lines:

    RewriteEngine On
    RewriteBase /

    Thanks for this Bob - appreciate you looking into it further.

    So The htaccess file is inherited so I'm not 100% sure about all of it's code - but below is whatI have:

    
    <IfModule mod_rewrite.c>
        Options +FollowSymlinks
      # Options +SymLinksIfOwnerMatch
        RewriteEngine On
       RewriteBase /
    </IfModule>
    
    
    
    <IfModule mod_rewrite.c>
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
        RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
        RewriteCond %{HTTP_HOST} !=localhost [NC]
        RewriteCond %{HTTP_HOST} !=127.0.0.1
        RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>
    
    Then I have this:
    
    <IfModule mod_rewrite.c>
        RewriteCond %{SERVER_PORT} !^443
        RewriteRule ^ https://www.domain.co.uk%{REQUEST_URI} [R=301,L]
     </IfModule>
    
    
    


    As i understand it, the first rewrite is to make sure all traffic goes via www... and the second part is supposed to ensure that https is used - but I am thinking that one is confusing the other maybe?

    The code you have is very similar to the second block of my code - but I'm not sure what I should remove/add?

    Thanks
    Andy
      • 3749
      • 24,544 Posts
      All of that, combined with the server_protocol set to https should definitely force https. If it doesn't, even after manually deleting all the core/cache files, it's time to file a ticket with the host.
        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
        • 51020
        • 670 Posts
        Quote from: BobRay at Feb 02, 2018, 01:55 PM
        All of that, combined with the server_protocol set to https should definitely force https. If it doesn't, even after manually deleting all the core/cache files, it's time to file a ticket with the host.

        Ok thanks bob - will do. It’s strange as it’s hosted on the same server as several other modx sites and they are all fine!

        Andy