• I saw this post already but I cant reply to it so I am starting another. I am trying to force all traffic:

    From
    https://example.com
    https://www.example.com
    https://www.example.com

    to

    https://example.com

    I think I have most of this except https://example.com is not forwarding currently. here is my htaccess configs:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    #Master Rule to chagne HTTP and WWW to HTTPS
    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    What am I missing

    The page I need help with: [log in to see the link]

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter Eric4381

    (@eryk4381)

    I am wondering if this would temporarily need port 80 for the non secure web traffic BEFORE its forced to SSL? If I dont have port 80 available the request traffic may not make it back to the client to switch to https but you would think it would since this should all be happening server side. Just throwing out ideas.

    everything is possible but I have no competence in this.
    But if you connect from the beginning in https you can’t see http 500 error.
    Use an online websniffer to verify that when you are in https there are no redirects.
    https://websniffer.cc/?url=https://stonesorganics.com/

    Thread Starter Eric4381

    (@eryk4381)

    Ever heard the statement that says “You can lock things down and secure things so tight that you cant get any work done”… I just did it to myself.

    So my rambling statement got me thinking and I decide to play with the htaccess rules we worked with but I edited to firewall to allow port 80 requests instead of only having port 443 open. (Side note… to auto renew SSL Certs with say CertBot you NEED port 80 open anyway or the secret challenges will error out which I was working on at the same time as this)

    In the end my two codes to change WWW to non-ww and http to https work! The site does it all now.

    Here is what I have for those two things:

    # BEGIN WordPress
    .....other code that does other stuff...
    
    #Force non-www V1
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    
    #Force all HTTP to HTTPS V1
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
    
    </IfModule>
    
    #End WordPress

    @autotutorial…. Thank you so much for working with me on this!! You are awesome!

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘Forcing http to https and non-www. to www.’ is closed to new replies.