301 redirection code on nginx

Source: Internet
Author: User

A website targeting Japan was launched recently. to speed up access to Japan, I used the dns Service dnsever in South Korea and got used to the free service. The first time I used the dns service, I ran into 301 redirection and asked for money. If I didn't spend any money, I had to jump to an advertisement.

I thought of using 301 redirection to redirect a domain name without www to a domain name with www

The following is the code, which is easy to use.

Replace the domain name in the Code with your own, and then add this code to the conf configuration file.

That is, put the files that are usually pseudo-static together.

If ($ host! = 'Www. jp ***. com') {rewrite ^/(. *) $ http://www.jp ***. com/$1 permanent ;}

Permanent indicates 301 permanent jump, and redirect indicates 302 temporary jump.

Depends on your taste.

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.