LNMP Series Tutorial: How to Set 301 redirects

Source: Internet
Author: User
Keywords Because LNMP

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

  

Because the LNMP system environment uses nginx instead of Apache, it is not simple to add code to the root directory when setting 301 redirects, because he needs to modify the configuration of the individual Web site conf file. Some friends want to say, why WordPress does not need to set, because of the particularity of the program, we create a blog when the choice is with the www or not with www, and then another will automatically internal redirection.

If you are another program you need to set it manually. The specific methods are as follows:

The first step, in our VPS under the/usr/local/nginx/conf/vhost/, we will see their own website name of the Conf file, and then the VI command to modify, you can also use FTP download to local changes and then passed up;

server_name www.laozuo.org laozuo.org;
if ($host!= ' www.laozuo.org ') {
Rewrite ^/(. *) $ http://www.laozuo.org/$1
permanent;
}
Index index.html index.htm index.php default.html default.htm default.php;

The above is modified, you compare, you lack, and then you can fill. Because I'm afraid everyone misplaced, so I copied the code before and after.

In the second step, we restart the LNMP using the following commands;

/ROOT/LNMP restart

In this way, you can enter the Web site without the WWW domain name, is not directly jump to the www. You do not trust, can also be detected through webmaster Tools is correct.

This article fixed link: http://www.laozuo.org/206.html | Old Left Blog

Related Article

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.