惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

安全 – Ed_'s Blog

简易个人数据备份方案 – yywr's Blog Keepass 使用记录 – yywr's Blog
[记录]WordPress全站开启SSL访问 – yywr's Blog
yywr · 2019-03-03 · via 安全 – Ed_'s Blog

环境背景:

  • WordPress 5.0
  • 使用DirectAdmin面板的虚拟主机

开启步骤

  1. DA面板SSL管理中一键申请Let’s Encrypt(需虚拟主机支持)
  2. DA面板 [更改设置]中[private_html安装 yywr.net – (SSL必须已经启动)]选项为:" 使用一个符号链接从private_html到public_html – 允许同样的数据在http和https中",这个选项确保HTTP和HTTPS使用同一个目录的内容.
  3. WP后台常规设置 WordPress地址和站点地址为https://www.yywr.net
  4. 开启后台SSL,在网站根目录下添加下面代码.(WP 5.0测试不添加也OK,应该是WordPress现在的版本自身支持)
/* 强制后台和登录使用 SSL*/
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);
  1. 更新站内图片链接,将站内绝对地址更新为相对地址,在当前主题根目录下的functions.php添加下面代码
//WordPress SSL
add_filter('get_header', 'fanly_ssl');function fanly_ssl(){
if( is_ssl() ){
function fanly_ssl_main ($content){
$siteurl = get_option('siteurl');
$upload_dir = wp_upload_dir();
$content = str_replace( 'http:'.strstr($siteurl, '//'), strstr($siteurl, '//'), $content);
$content = str_replace( 'http:'.strstr($upload_dir['baseurl'], '//'), strstr($upload_dir['baseurl'], '//'), $content);
return $content;
}
ob_start("fanly_ssl_main");
}}
  1. 添加301跳转,在网站根目录下的.htaccess添加下面代码
#开启 HTTPS 的301重定向
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

参考资料:

  • 测试安全性:https://www.ssllabs.com/ssltest/
  • https://kzyblog.com/3760.html
  • https://zhangzifan.com/wordpress-ssl-link.html
  • https://www.wpdaxue.com/wordpress-forces-http-redirection-to-https-under-apache-host.html