一、获取并配置 https 证书
1、密码和证书-https(ssl/tls)之证书的概述及获取和网站部署 ,使网站能够通过https访问。
2、配置服务器,将网站从 http 跳转到 https。
### nginx 服务器 http 跳转 https 的配置如下 server { listen 80; server_name www.huaijiujia.com; return 301 https://www.huaijiujia.com$request_uri; }
二、编辑 wp-config.php 文件
# 添加下面这句话,使php网站 从 http 强制跳转到 https define('FORCE_SSL_ADMIN', true);
三、其他操作
If that worked fine, now it’s time to do the last few steps to complete the transfer to HTTPS:
- Update your sitemap — Ideally, your SEO plugin does this automatically. However, it doesn’t always work that way. With Yoast SEO you might have to switch off the plugin once for it to update the sitemap. Don’t forget to include it in your robots.txt file and update all other hardcoded links you might have there.
- Add site to your webmaster tools — Go to every webmaster tool you are using and add the HTTPS version of your site as a new property. While you are there, upload the new sitemap. You might also consider doing a fetch and crawl and submit any disavow files that are already active for the old version of your site.
- Update your CDN — If you are using a content delivery network (one of the ways to speed up your site), you also need to switch it to SSL. Many of them have that feature built in and your CDN should have documentation on this. Otherwise, ask their support to help you.
- Make the switch in your analytics — If your analytics need a default URL, make sure to upgrade it with the new prefix. For Google Analytics, you find the option under Admin > Property Settings > Default URL. Also, note down when you made the switch to HTTPS to understand traffic changes.
- Preserve social share counts — If you show social share counters on your site, you might have to make some changes in order to keep them up to date. Check this guide for details. Don’t forget to update the links to your site in your social profiles! And do the same in your email templates.
参考自:https://websitesetup.org/http-to-https-wordpress/#comment-131467