Based on SEO and security considerations, a 301 redirect is required. Nginx is used for general processing below. Achieve Results The following addresses need to be redirected to the root domain name of https://chanvinxiao.com
The difference between 301 and 302 301 is a permanent redirect, 302 is a temporary redirect, the main difference is how search engines treat it
Now we want the search engine to think that the original address no longer exists and completely transfer it to the new address, so we use 301 http jump to https The simplest way is to return a redirect address directly in the server, and add a 301 status code in the middle (otherwise the default is 302) server { listen 80; return 301 https://$host$request_uri; }
www jumps to the root domain name This only needs to be processed in https, because all http will jump to https server { listen 443 ssl; server_name ~^(?<www>www\.)?(.+)$; if ( $www ) { return 301 https://$2$request_uri; } ...
Reduce the number of jumps The above settings have met the requirements, but there is a flaw. http://www.chanvinxiao.com will first jump to https://www.chanvinxiao.com, and then jump to https://chanvinxiao.com. The second jump is definitely not as good as the first jump. So it is better to do it in one step. Modify the http configuration as follows: server { listen 80; server_name ~^(?:www\.)?(.+)$; return 301 https://$1$request_uri; } In the server corresponding to http, change server_name to regular mode and replace $host with the captured root domain name $1 Summarize The above configuration does not require a specific domain name, which is convenient for compatibility and portability. It uses the following features of Nginx:
This is the end of this article about using Nginx to implement 301 redirect to https root domain name. For more relevant content about Nginx 301 redirect to https root domain name, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: jQuery custom magnifying glass effect
>>: Vue implements a search box with a magnifying glass
add -it docker run -it -name test -d nginx:latest...
rep / egrep Syntax: grep [-cinvABC] 'word'...
Verification environment: [root@~~/]# rpm -qa | g...
1. Download Python 3 wget https://www.python.org/...
Table of contents 1. World Map 1. Install openlay...
Table of contents 1. Index Basics 1.1 Introductio...
Preface About the performance comparison between ...
There are three ways to interconnect and communic...
Table of contents 1. Purpose 2. Grammar 3. Practi...
Click here to return to the 123WORDPRESS.COM HTML ...
Table of contents 1. Ordinary functions 2. Arrow ...
Jenkins configuration of user role permissions re...
Table of contents Preface Six features of JSON.st...
@vue+echarts realizes the flow effect of China ma...