HTTP to HTTPS – Too many redirects

I have a site with WordPress. I need some single page to redirect HTTPS

I get code form stackoverflow and put in .htaccess

Read More
        # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{HTTPS} off
    RewriteCond %{THE_REQUEST} /online-order-auto [NC]
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

    RewriteCond %{HTTPS} on
    RewriteCond %{THE_REQUEST} !/online-order-auto [NC]
    RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

    RewriteRule ^index.php$ - [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    RewriteCond %{HTTP_HOST} ^(www.)?site.com.swtest.ru$
    RewriteRule ^(.*)$ http://www.site.ru/$1 [L,R=301]

The browser wrote “ERR_TOO_MANY_REDIRECTS”.
I cant understand whats a problem

Related posts

1 comment

  1. Try this. I’ve been looking all over and this is the only way I could make it work…

    #non-www. http to www. https
    RewriteCond %{ENV:HTTPS} !on
    RewriteCond %{HTTP_HOST} ^(www.)?yourdomain.com$
    RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]
    
    #non-www. https to www. https
    RewriteCond %{ENV:HTTPS} on
    RewriteCond %{HTTP_HOST} ^yourdomain.com$
    RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]
    

Comments are closed.