return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>Redirect too many times htacces switching to https
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Redirect too many times htacces switching to https

programmeradmin2浏览0评论

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
Add a comment  | 

3 Answers 3

Reset to default 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.

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

发布评论

评论列表(0)

  1. 暂无评论