Attention 1. Baidu has solved this problem( http://zhanzhang.baidu.com/wiki/494 )However, unsupported spiders still exist (such as Youdao, etc.). 2. The method of setting and obtaining SSL certificate is not described in detail. Please Baidu by yourself. (of course, I will write it if I really have a request ~) 3. The file manager of cPanel is not displayed Htaccess file. The solution is to click the setting in the upper right corner of the file manager and check "dotfiles". Average The htaccess file is located in the root directory of the website and is hidden by default.
Compatibility with https and some domestic engine spiders has always been a headache for many people. There is no doubt that https is very safe, but it will affect the capture of some domestic engine spiders. This tutorial is to give consideration to both sides.
Premise: you can access your website by entering http and https, and http access will not automatically jump to https. You can visit your website htaccess file.
Method: change htaccess file.
The first is to make sure that all visits jump to https. It's not difficult to do this. There are many online tutorials, so I don't introduce them in detail. The only thing to note is that the https jump should exclude some domestic engine spiders. So we need to add a jump condition (high bright line). Note that please refer to www.example.com Com for your website address.
#HTTPS redirection RewriteCond %{HTTP_USER_AGENT} !(360spider|haosouspider|youdaobot|yodaobot|sogou|sohu-search|easouspider|yisouspider) [NC] RewriteCond %{SERVER_PORT} !^443$ RewriteCond %{HTTP_USER_AGENT} !MSIE/[1-8]\. [NC] RewriteCond %{HTTP_HOST} www.example.com RewriteRule ^.*$ https://www.example.com%{REQUEST_URI} [L,R=301]
On your website Add the above content to the htaccess file (after the "RewriteEngine On" line). Now you can test it. In chrome, press F12 to open the debug window.

Select the "Network Conditions" Tab page in the lower left corner, and check "Custom user agent" in "User agent spoofing" below.

Select "Other" in the drop-down option, and enter the UA of some domestic engine spiders in the edit box below to simulate the capture of some domestic engine spiders.
Baidu spider's UA: Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html) Youdao spider UA: Mozilla/5.0 (compatible; YoudaoBot/1.0; YoudaoBot)
Then enter your website URL (http access) in the URL column. If you don't jump to https access, it means success. Moreover, when "Auto user agent" is selected, you can jump to https to access your website URL (http access), and the first stage is successful.
So the question is, how can some domestic engine spiders access https? It's unlikely, but for insurance, we'll add the following htaccess file. Note that please refer to www.example.com Com for your website address.
#Jump http judgment RewriteCond %{HTTP_USER_AGENT} (360spider|haosouspider|youdaobot|yodaobot|sogou|sohu-search|easouspider|yisouspider) [NC] RewriteCond %{SERVER_PORT} ^443$ RewriteRule ^.*$ http://www.example.com%{REQUEST_URI} [L,R=301]
Note the highlighted line. If there is no such line, it will lead to page redirection cycle. Please be careful. Now you can test again. Re check "Custom user agent" in the Tab just now and try https access. Is it successful to jump to http access now?
Finally, to sum up, in Add the following to the htaccess file (after the "RewriteEngine On" line):
#HTTPS redirection RewriteCond %{HTTP_USER_AGENT} !(360spider|haosouspider|youdaobot|yodaobot|sogou|sohu-search|easouspider|yisouspider) [NC] RewriteCond %{SERVER_PORT} !^443$ RewriteCond %{HTTP_USER_AGENT} !MSIE/[1-8]\. [NC] RewriteCond %{HTTP_HOST} www.example.com RewriteRule ^.*$ https://www.example.com%{REQUEST_URI} [L,R=301] #Jump http judgment RewriteCond %{HTTP_USER_AGENT} (360spider|haosouspider|youdaobot|yodaobot|sogou|sohu-search|easouspider|yisouspider) [NC] RewriteCond %{SERVER_PORT} ^443$ RewriteRule ^.*$ http://www.example.com%{REQUEST_URI} [L,R=301]
Note that please refer to www.example.com Com for your website address.
So that's it, isn't it very simple? If you have any comments or questions, please reply below or to the message board in the upper right corner of the page.