Detailed explanation of the solution to the Baidu https authentication prompt "Please redirect your http site 301 to the https site"

Detailed explanation of the solution to the Baidu https authentication prompt "Please redirect your http site 301 to the https site"

I recently wanted to convert a website to https access, but after I had done everything, I went to Baidu Webmaster Platform to authenticate https, but no matter how I submitted it, it kept saying "Please redirect your http site 301 to the https site". I asked questions in the Baidu Webmaster Community, but no one answered, so I had to figure it out on my own. Later I found the reason: Baidu's https authentication strictly abides by 301 redirection. I used IIS6, and the previous code was:

RewriteEngine On

RewriteCond %{SERVER_PORT} !^443$ 

RewriteRule (.*) https://%{SERVER_NAME}/$1 [R] 

Although this writing method can redirect all http to https, it will not pass the Baidu Webmaster Platform. Finally, the code was modified to the following and passed

RewriteEngine On

RewriteCond %{SERVER_PORT} !^443$

RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

Below I have collected and sorted out the code for setting up 301 redirects after deploying https (ssl) in various website environments. I hope it will be helpful to everyone.

Linuxt system Apache environment

Cloud server: Create a new file named .htaccess in the root directory of the corresponding site (via FTP or logging in to the wdcp management panel: Site List - Document Management - Enter public_html - Create File).

Virtual host: You can enter the host management panel-File Management through FTP or after logging in, enter wwwroot, create a new file named .htaccess file, and save it.

Edit the .htaccess file and add the following rules:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:From-Https} !^on$ [NC]
RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L] # Change www.abc.com to your own domain name RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ https://www.abc.com$1 [R=301,L] # Change www.abc.com to your own domain name</IfModule>

Nginx Environment

Edit the nginx site configuration file (log in to the wdcp management panel: site list-document management-virtual host site file nginx-corresponding site configuration file), add the following rules

server
{
listen 80;
server_name abc.com;
rewrite ^(.*) https://www.abc.com$1 permanent; # Change abc.com to your own domain name}

Windows System II7 Environment

Cloud server: Create a new file in the root directory of the corresponding site (via FTP or directly enter D:\wwwroot\site ftp naming directory\wwwroot after logging in) named web.config and edit it to add the following rules:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <rewrite>
   <rules>
    <rule name="301" stopProcessing="true">
     <match url="^(.*)$" ignoreCase="false" />
     <conditions logicalGrouping="MatchAll">
      <add input="{HTTPS}" pattern="^on$" negate="true" />
     </conditions>
     <action type="Redirect" url="https://www.abc.com/{R:1}" redirectType="Permanent" /> # Change www.abc.com to your own domain name</rule>
   </rules>
  </rewrite>
 </system.webServer> 
</configuration>

Virtual host: You can enter the host management panel-file management through ftp or login, enter wwwroot, create a new file named web.config and edit and add the following rules:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <rewrite>
   <rules>
    <rule name="301" stopProcessing="true">
     <match url="^(.*)$" ignoreCase="false" />
     <conditions logicalGrouping="MatchAll">
      <add input="{HTTP_FROM_HTTPS}" pattern="^on$" negate="true" />
     </conditions>
     <action type="Redirect" url="https://www.abc.com/{R:1}" redirectType="Permanent" /> # Change www.abc.com to your own domain name</rule>
   </rules>
  </rewrite>
 </system.webServer> 
</configuration>

Windows System II6 Environment

Configure a Rewrite, edit the Rewrite rule file httpd.conf or .htaccess and add the following rules.

RewriteEngine On

RewriteCond %{SERVER_PORT} !^443$

RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

tomcat environment

Add the following code before the last line of </web-app> in web.xml

<security-constraint>
 <!-- Authorization setting for SSL -->
 <web-resource-collection>
  <web-resource-name >SSL</web-resource-name>
  <url-pattern>/*</url-pattern>
 </web-resource-collection>
 <user-data-constraint>
  <transport-guarantee>CONFIDENTIAL</transport-guarantee>
 </user-data-constraint>
</security-constraint>

Note: 1. When discuz uses the 301 method to force http to jump to https, it will cause the background UC communication to fail.

2. After setting up the redirect in this way, if you cannot redirect normally, please establish a separate site binding https domain name and still set up the jump rules on the original site.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  How to create an index on a join table in MySQL

>>:  js canvas realizes slider verification

Recommend

Implementation of MySQL multi-version concurrency control MVCC

Transaction isolation level settings set global t...

Use of MySQL stress testing tool Mysqlslap

1. MySQL's own stress testing tool Mysqlslap ...

JavaScript to achieve balance digital scrolling effect

Table of contents 1. Implementation Background 2....

26 Commonly Forgotten CSS Tips

This is a collection of commonly used but easily ...

In-depth study of MySQL multi-version concurrency control MVCC

MVCC MVCC (Multi-Version Concurrency Control) is ...

CentOS7 deployment Flask (Apache, mod_wsgi, Python36, venv)

1. Install Apache # yum install -y httpd httpd-de...

Circular progress bar implemented with CSS

Achieve results Implementation Code html <div ...

CSS code to achieve background gradient and automatic full screen

CSS issues about background gradient and automati...

Vue realizes web online chat function

This article example shares the specific code of ...

Introduction to ufw firewall in Linux

Let's take a look at ufw (Uncomplicated Firew...

Implementation of Nginx configuration of local image server

Table of contents 1. Introduction to Nginx 2. Ima...

What should I do if I can't view the source file of a web page?

Q: Whether using Outlook or IE, when you right-cl...

Docker practice: Python application containerization

1. Introduction Containers use a sandbox mechanis...