使用 WordPress Really Simple SSL 插件
sudo a2enmod rewrite
#启动rewrite mod.htaccess
文件,在文件中输入内容:RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
更多关于重定向内容:https://jingyan.baidu.com/article/09ea3ede6bd7c6c0aede3931.html
敲黑板,如果.htaccess
文件中原本就有伪静态代码,要把上面的代码放在URL-rewrite代码之前。
update wp_options set option_value = ‘https://domain.com’ where option_id in(1,2);
update wp_posts set post_content = replace(post_content, 'http://domain.com','https://domain.com');
最后重启下apache服务:
sudo service apache2 restart
对数据库错误的更新对网站可能是毁灭性的打击,建议更新前最好备份数据库。
via https://www.cnblogs.com/xjb/archive/2017/04/16/wordpress-https-link.html via https://blog.csdn.net/WsXOM853BD45Fm92B0L/article/details/80115863