Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

        # 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

like image 686
Romancho Avatar asked Jun 02 '26 11:06

Romancho


1 Answers

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]
like image 113
João Henrique Silveira Avatar answered Jun 05 '26 01:06

João Henrique Silveira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!