如何将WordPress从HTTP移到HTTPS [英] How to move WordPress form HTTP to HTTPS

查看:82
本文介绍了如何将WordPress从HTTP移到HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在wp网站的.htaccess文件中有以下代码

I have following code in my .htaccess file of a wp site

# 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

我已经完成了WordPress网站可运行的所有操作HTTPS现在,我的网站同时以HTTP和HTTPS两种格式打开,但是如果用户键入example.com,它将转到http而不是https,要解决此问题,我添加了一些代码来解决此问题

I have done all the thing need for a WordPress site to operate in HTTPS now my site is opening in both the format i.e in HTTP and HTTPS, but if the user type example.com it goes to http not in https so to solve this I add few more code to solve this issue

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

# 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

,但是在未打开此网站后,我说了 ERR_TOO_MANY_REDIRECTS

but after adding this my site in not opening it says "ERR_TOO_MANY_REDIRECTS"

如何解决此问题,我希望用户直接转到https

How to solve this issue, I want the user to go directly to https

推荐答案

问题是您没有检查是否正在使用https,因此它只会不断告诉浏览器转到 https://www.yoursite.com/$1

The problem is that you're not checking if https is being used, so it just constantly tells the browser to go to https://www.yoursite.com/$1.

您可以使用%{HTTPS} 检查请求是否使用https。

You can use %{HTTPS} to check whether the request uses https.

RewriteEngine on
RewriteCond %{HTTPS} !^on$ [NC]
RewriteRule ^(.*)$ https://www.yoursite.com/$1 [L,R=301,NC]

这篇关于如何将WordPress从HTTP移到HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆