The nginx301 jump setting is simple and is configured as follows. (The configuration file defaults to nginx.conf, if a new configuration file is developed, the new file configuration is available.)
server{
server_name xxx.com www.xxx.com;
Rewrite ^/(. *) http://www.hablue.com/$1 permanent;
}
server{
server_name xxx.com www.xxx.com;
if ($host! = ' www.hablue.com ') {
Rewrite ^/(. *) $ http://www.hablue.com/$1 permanent;
}
}
Both of these scenarios can be implemented, remember not to and virtual host configuration in a server, so as not to cause cyclic redirection.
In addition, there is a situation is not with the WWW jump to the domain name with www, this is more conducive to the site rankings.
Server
{
Listen 80;
server_name www.hablue.com hablue.com;
if ($host! = ' www.hablue.com ') {
Rewrite ^/(. *) $ http://www.hablue.com/$1 permanent;
}
——————————————————————————————
Someone might confuse DNS parsing with 301 jumps. They do have a connection, 301 jump is the domain name directly to the existing domain name, for example, input xxx.com will jump directly to hablue.com, input xxx.com/1111 will jump to hablue.com/111. Domain name binding is the input domain name what is what, even if the next add directory will not change, so it can only rely on it to open the home page. The 301 jump premise is that the domain name to jump must be bound to the IP of the existing machine, otherwise it will prompt couldn ' t resolve host ' xxx.com ’.
Nginx 301 Permanent Redirect