3

When I change the redirect https in my .htaccess the site returns the message "Too many redirects" loop.

This is the modified .htaccess

RewriteCond %{HTTPS} off
RewriteRule (.*)$ https://www.mywebsite.it/$1 [L,R=301]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I also added in the wp-config.php:

define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);

3 Answers 3

1

Adding redirect to htaccess in the way that you have done will not work without adjudicating the site url to be https as well. If it is http, you will get endless redirect due to wordpress detecting that you are trying to access a non canonical URL (the https), and will try to redirect you to the canonical one, which is based on the site url, which is http, and then the htacess will redirect to https again only for wordpress to redirect to http, and so on.

1
  • 1
    Check the URLs specified in the wp-options table. Should include https, not http. That's what Mark is indicating. Sep 29, 2018 at 0:44
0

Since many shared hosts use additional DNS management now such as such as Cloudflare...or similar, do you know if you are using such thing ?

If so you need to make sure cloudflare is set to Full https as well as possibly using a cloudflare plugin to prevent too many redirects or loops.

-1

do you want to push all the traffic to https?

i have ssl installed on my site, and i use this code to force all the incoming traffic to HHTPS : (put it above all of your codes in .htaccess )
first remove the previous code you added to wp-config.php
and remove the previous code in .htaccess

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.yoursite.it/$1 [R,L]

be sure to know your server port. and replace it if it's not 80.

here is more info if you need : - i took my code from here :)

i hope it help you too

use https with .htaccess

2
  • yes, the site is on a shared hosting which provides the SSL activation but since the coexistence also the version of the website http must force the redirect via https. I tried your solution but it does not work. Feb 25, 2017 at 21:51
  • @user1269141 my site is on a shared host too. 1 - did you go to the link i posted at the end of my answer? 2 - go to Dashboard> setting > General> change your site address and put https:// at the first of your site address and hit save. 3 - after this , please first clear the browser cache - and type your site address without https, to see if the redirection works or not?
    – Poofy
    Feb 26, 2017 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.