方法一
使用 WordPress Really Simple SSL 插件
方法二
- 启动重定向:
sudo a2enmod rewrite
#启动rewrite mod - 设置http端口重定向,在网站根目录wordpress下新建
.htaccess
文件,在文件中输入内容:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ [R=301,L]
RewriteCond %{HTTP_HOST} [NC]
RewriteRule ^(.*)$ [L,R=301]
- 将数据库写死的http修改为https
服务器上进入当前数据库:
update wp_options set option_value = where option_id in(1,2);
update wp_posts set post_content = replace(post_content,
最后重启下apache服务:
sudo service apache2 restart
对数据库错误的更新对网站可能是毁灭性的打击,建议更新前最好备份数据库。