大网数据广告活动
网站运营与故障问答

Is an .htaccess edit necessary when enabling Cloudflare SSL?

· 52CE 我爱测

I have recently changed 3-4 of my sites to Cloudflare SSL. After that, I went to General Settings on WordPress and changed URLs from HTTP to HTTPS. And it redirects from HTTP to HTTPS without any issues. But I read many posts on …

问题原文

原帖链接 · V3King · CC BY-SA 4.0

I have recently changed 3-4 of my sites to Cloudflare SSL. After that, I went to General Settings on WordPress and changed URLs from HTTP to HTTPS.

And it redirects from HTTP to HTTPS without any issues. But I read many posts on various blogs and they all mention adding .htaccess redirect.

Is that really necessary? I'm confused as the redirect is already in place.

社区高分解答

原帖链接 · DocRoot · CC BY-SA 4.0

It's really to do with when the redirect occurs.

WordPress/PHP naturally occurs later than .htaccess, so the HTTP request has already passed to PHP before the redirect occurs.

.htaccess is processed at the very start of the request, before it is passed to PHP.

However, if you are using CloudFlare then you should create a page rule to redirect HTTP to HTTPS to avoid unnecessary hits on your application server.

From a security point of view, you want to redirect to HTTPS as soon as possible.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2018-06-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。