Nginx 301 Permanent Redirect

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.