首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在为站点启用SSL时修复过多的重定向?

如何在为站点启用SSL时修复过多的重定向?
EN

WordPress Development用户
提问于 2018-05-27 12:46:07
回答 2查看 6.8K关注 0票数 0

我有一个使用wordpress的网站。它最初是在没有SSL的情况下上传和使用的。在安装了服务器证书并为ssl站点添加了apache虚拟主机文件之后,我尝试加载https版本。它装载了许多关于不安全内容正在被裁剪的警告。由于不安全的http协议,许多与wordpress主题相关的css和javascript文件没有被加载,因此产生的网页看起来很难看。

我将.htaccess更改为:

代码语言:javascript
复制
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://drjoel.info/$1 [R,L]

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

然后,我按照代码索引说明,将mysql数据库中的"Home“和"Site URL”更改为http中的https。当我再次尝试加载时,浏览器一直显示“太多重定向”错误。我在wget中使用详细和调试选项进行了检查。我得到的是:

代码语言:javascript
复制
---request begin---
GET / HTTP/1.1
User-Agent: Wget/1.19.1 (linux-gnu)
Accept: */*
Accept-Encoding: identity
Host: drjoel.info
Connection: Keep-Alive
Cookie: __cfduid=d700f224676946c9ea07ab3eb7cf5cb861527424630

---request end---
HTTP request sent, awaiting response... 
---response begin---
HTTP/1.1 302 Found
Date: Sun, 27 May 2018 12:37:11 GMT
Content-Type: text/html; charset=iso-8859-1
Transfer-Encoding: chunked
Connection: keep-alive
Location: https://drjoel.info/
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 42188807c86caaaa-SIN

---response end---
302 Found
URI content encoding = ‘iso-8859-1’
Location: https://drjoel.info/ [following]
Skipping 204 bytes of body: [

302 Found

Found
The document has moved here.

] done.
URI content encoding = None
Converted file name 'index.html' (UTF-8) -> 'index.html' (UTF-8)
--2018-05-27 18:07:11--  https://drjoel.info/
Reusing existing connection to drjoel.info:443.
Reusing fd 3.

这种情况在wget中止之前重复了大约20次。出什么问题了?对Wordpress上的站点启用SSL的正确技术是什么?

EN

回答 2

WordPress Development用户

发布于 2018-05-27 13:14:06

在我看来,使用来自web服务器的重定向并不是最好的解决方案。

相反,为什么不直接修复数据库的内容呢?(使用https://而不是到处使用http://

您可以使用WordPress插件(如WP迁移DB或命令行工具可湿性粉剂 )来实现这一点。

使用插件选项(WP Migrate DB),在管理中转到Tools > Migrate DB

使用命令行工具(WP-CLI),请使用以下命令行:wp search-replace http://oldurl.com https://oldurl.com

在应用这两种解决方案之一之后,您应该有一个正确的站点,它使用https urls而不是http

票数 1
EN

WordPress Development用户

发布于 2018-05-29 07:06:32

我同意@Mike,避免http重定向,并替换文件和DB中的字符串。替换字符串(甚至序列化)的另一个有用工具-no命令行--是这样一个:https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

票数 1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/304568

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档