Modification methods and precautions for fully enabling https on WordPress blogs

888u

Last update at :2024-01-01,Edit by888u

Now that HTTPS access has been enabled for the entire site, the process is still full of challenges. After all, there are still many places to modify, and it took 3 days of intermittent work. Previously, this website combined the experience of some netizens to write an article "Question: Should the website be SSL? What are the advantages and disadvantages of HTTPS?". Indeed, I saw that many small partners' small websites were using https, and I thought Wondering if I should enable it. This idea has been lingering on, and I have been thinking about whether to use free or paid SSL certificates. Finally, I chose a paid SSL certificate. It only costs tens of yuan a year, which is quite affordable.

In the long run, SSL has become a trend, especially Google, which has always been at the forefront, has clearly pointed out that the rankings are better, and Baidu, 360, etc. in mainland China are also gradually improving SSL-related information , I believe there will be better support soon! Anyway, I have to try everything...

Now let me share the process of adding an SSL certificate to my blog to enable HTTPS access for the whole site. Before adding the SSL certificate, it is recommended to package and back up the entire website (including the database). This step is necessary; if you use For backup or snapshot cloud servers, it is recommended to start your own troublesome work after backing up.

Regarding how to choose an SSL certificate and how to configure an SSL certificate, most SSL certificate sellers will provide some tutorials. For free, you can also find related installation tutorials. You will know how to operate them. This step will be supplemented later. Mainly This site uses the commercial paid version of AMH5.x. It is very simple to install and configure SSL. It can be operated directly in the AMH background, which only takes a minute or two.

The installation is very easy, but it takes a lot of time to debug the whole site to enable 301 jumps, especially 301 jumps. If the settings are not good, the jump will not occur. In addition, after enabling SSL, the thumbnails may be displayed abnormally, etc. These problems all exist. For example, this site is like this now. A common problem with large front-end themes is that if the domain name is changed or changed to HTTPS mode, the thumbnails will not be normal. , the specific step is still being slowly searched.

Now let’s talk about how I replaced all internal link URLs with Https; for WordPress, you can use the plug-in: Search & Replace; you can also directly use SQL query operations; the latter is used on this site, and the most important thing is that the former does not appear after clicking Reaction, the latter operation only takes 1 minute to complete.

Specific method:

The execution of URLs such as the website homepage and website articles is completed. Some links in the articles and the URLs of pictures are still old URLs. If we want to update these URL addresses, we need to manually operate the mysql database and execute the following sql in sequence. Statement:

UPDATE wp_posts SET post_content = replace( post_content, 'https://www.this site.com','https://www.this site.com');
UPDATE wp_comments SET comment_content = replace(comment_content, 'https://www.this site.com','https://www.this site.com');
UPDATE wp_comments SET comment_author_url = replace(comment_author_url, 'https://www.this site.com','https://www.this site.com');

Note: https://www.this site.com in the sql execution statement refers to the old domain name, while https://www.this site.com refers to your new domain name, which should be changed to Just make your own!

This basically completes the replacement of some links in the article and the URLs of the pictures; in addition, you also need to modify some pages that you have manually added, which basically only takes a few minutes. This requires you to manually add the pages yourself. How much.

After modifying some links in the article and the URLs of the pictures, the next step is to redirect the domain name 301. The Linux server used by this site uses Nginx, so the conf rules need to be modified. The specific path will be different for different servers, but the general method is similar, usually in the vhost file.

1. Open the conf file (if you are using the LNMP0.6 all-in-one package, it is in /usr/local/nginx/conf/vhost/this site.com.conf. If you are using the AMH5.x paid version, log in directly You can see it via FTP)

2. Normally, the front part of conf is displayed like this:


server
{
 listen 80; #listen end
 server_name this site.com www.this site.com; #server_name end
 index index.html index.htm index.php; #index end

3. Now you need to add a 301 permanent redirection rule of the Nginx server conf under server_name this website.com www.this website.com;:


if ($host != 'www.thissite.com' ) {
rewrite ^/(.*)$ https://www.thissite.com/$1 permanent;
}

or

rewrite ^/(.*)$ https://www.thissite.com/$1 permanent;

Upload the modifications to the server and restart the Nginx server to take effect;

Note: Please choose the above two adding methods according to your own configuration. This site uses the second one.

If HTTPS is enabled on the entire site, various incompatibility issues will occur. For example, Baidu site search does not support HTTPS, and the template needs to be modified in many places; it is not recommended for novice friends.

Recommended site search: PHP space application, overseas virtual host space, registered domain name, IP segment query, independent IP host, Alibaba Cloud domain name registration entrance, free cloud host, Alibaba Cloud server, Hong Kong server hosting, website registration system

Modification methods and precautions for fully enabling https on WordPress blogs

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码