At present, https is the general trend. Baidu and Google have stated that pages using https protocol are more secure and will be given priority in rankings. Life is endless and the tossing is endless. Let’s share the entire WordPress site. Enable https to access practical tutorials.
1. Apply for an SSL certificate
To enable https on a website, you must first configure an SSL certificate, but the key point is to first have an SSL certificate. Initially, because SSL certificates are expensive, many personal webmasters will If you choose to give up using HTTPS, domestic Alibaba Cloud, Tencent Cloud, and Qiniu now have free certificates that you can apply for.
2. Install the SSL certificate
After we successfully apply for the SSL certificate, download and decompress the certificate file. They are the certificate files of Apache, IIS, and Nginx servers. Tencent Cloud officially gave us Examples of 4 types of server certificate installation methods are provided. The tutorial is very detailed and we can refer to it: SSL Certificate Installation Guide
WordPress Website Configuration
1. Enter In the WP backend, go to Settings-General and change the WordPress address (URL) and site address (URL) to: https.
#2. Force SSL to be turned on during login and background.
By modifying the WP-config.php file, add the following two lines of code directly at the end of the file:
/* 强制后台和登录使用 SSL */ define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true);
3. In order to ensure that the various links or multimedia files previously added to the WordPress site change the http protocol To achieve https protocol, we also need to execute a replacement command through database SQL query. The code is as follows: (When using it, please modify it according to your own database table name (wp_posts) and website domain name before executing it.)
update wp_posts set post_content = replace(post_content, 'http://ws234.com','https://ws234.com');
4 , it’s done, what we need to do next is to change the external link to the new https address, and at the same time visit the https version page, including the home page, column page, inner page, sitemap, check the source code to see if there is still an http address exist.
For more wordpress related technical articles, please visit the wordpress tutorial column to learn!
The above is the detailed content of How to enable https in wordpress. For more information, please follow other related articles on the PHP Chinese website!