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

推荐订阅源

T
The Blog of Author Tim Ferriss
TaoSecurity Blog
TaoSecurity Blog
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题
T
Troy Hunt's Blog
N
News and Events Feed by Topic
雷峰网
雷峰网
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
PCI Perspectives
PCI Perspectives
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 三生石上(FineUI控件)
Schneier on Security
Schneier on Security
T
The Exploit Database - CXSecurity.com
L
LINUX DO - 最新话题
V
V2EX
T
Threat Research - Cisco Blogs
人人都是产品经理
人人都是产品经理
C
Cisco Blogs
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
I
Intezer
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
月光博客
月光博客
Recent Commits to openclaw:main
Recent Commits to openclaw:main
N
News | PayPal Newsroom
Cyberwarzone
Cyberwarzone
B
Blog
博客园 - 聂微东
P
Palo Alto Networks Blog
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog
Scott Helme
Scott Helme
Google DeepMind News
Google DeepMind News
Webroot Blog
Webroot Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
O
OpenAI News
C
Check Point Blog
Hacker News: Ask HN
Hacker News: Ask HN
W
WeLiveSecurity
V
Vulnerabilities – Threatpost
博客园 - 【当耐特】
有赞技术团队
有赞技术团队
A
Arctic Wolf

安全 – 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