The first case: access to the AAAAAAA station directed to the BBBBBBBBBBB station
| The code is as follows |
Copy Code |
server { Server_naaaaaaame www.aaaaaaa.com; rewrite ^ (. *) http://www.bbbbbbbbbbb.com$1 permaaaaaaanent; •}
|
In the second case: not all redirects to the AAAAAAA station are redirected to the specified page
| The code is as follows |
Copy Code |
server { Server_naaaaaaame www.aaaaaaa.com; if ($host!= ' aaaaaaa.com ') {rewrite ^/(. *) $ http://www.bbbbbbbbbbb.com/$1 permaaaaaaanent;}
|
will also be redirected if write is used for IP access in the first server segment
A third type of jump with www or without www
| The code is as follows |
Copy Code |
Server •{ Server_naaaaaaame c.net rewrite ^/(. *) $ http://www.c.net/$1 permaaaaaaanent; •} |
The following is a nginx rule jump:
First, in your domain name management inside the definition of c.com and www.c.com point to your host IP address, we can use the nslookup command test: Direct input nslookup c.com and Nslookup have a record point to IP.
Second, we can configure rewrite rules within the nginx. Open nginx.conf File
Find your server configuration segment: "The following is my server configuration segment"
| The code is as follows |
Copy Code |
Server { Listen 80; server_name www.c.com c.com; if ($host!= ' www.c.com ') { Rewrite ^/(. *) $ http://www.c.com/$1 permanent; }
|
This is the user directly access c.com direct jump www.c.com. That is, let the domain name without www jump to the domain name with www.
Third, we can be more than two domain names, three-level domain name can jump at will, or let them all jump to blog.c.com this domain name
Agree to add the following statement:
| code is as follows |
copy code |
server { Listen 80; server_name blog.c.com wgkgood.gicp.net; if ($host = ' wgkgood.gicp.net ') { rewrite ^/(. *) $ http://blog.c.com/$1 permanent; } |