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 (.*)$ /$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);
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);
Share
Improve this question
asked Feb 25, 2017 at 21:09
user1269141user1269141
311 silver badge2 bronze badges
3 Answers
Reset to default 1Adding 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.
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.
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