Under the macro control of the country, if a website accidentally leaves the country, it is helpless. in a harmonious society, everyone should do their best. Windows hosts outside China are expensive. Linux is much cheaper than windows because the system is free of charge. Although I have never used Linux before, I have bought a Linux VPS (
Under the macro control of the country, if a website accidentally leaves the country, it is helpless. in a harmonious society, everyone should do their best. Windows hosts outside China are expensive. Linux is much cheaper than windows because the system is free of charge. Although I have never used Linux before, I still bought a Linux VPS (I can't afford it on an independent server, and it's not necessary). So I learned how to install the Lnmp one-key installation package, everything went well. In the past few days, I have to change the website address. based on the SEO idea, I am going to get a 301 permanent redirection. so I found some information on the website and it was still quite smooth. I just got it done without any effort.
Let's talk about the method. I will not talk about the specific Lnmp installation, and I will not be refined. 301 redirection is mainly used to modify the core variable of nginx and the server function of the conf file of the target website.
For example, to redirect 2cto.com to www.2cto.com, modify the code as follows:
Server {
Server_name www.2cto.com 2cto.com;
If ($ host! = 'Www .2cto.com '){
Rewrite ^/(. *) $ http://www.2cto.com/#1 permanent;
Proxy_set_header Host "www.2cto.com ";
}
...
}
You can change the domain name to yours. Note the following two points:
1. permanent: this is the key, indicating permanent orientation;
2. the role of the following code:
Proxy_set_header Host "www.2cto.com ";
This code can be added, but the effect is different. If 2cto.com or Taobao is not input /. You can choose whether to add or not to this code as needed.
Note: After testing, the code proxy_set_header Host "www.2cto.com" is added. The Test will result in an error and you can jump to the internal page without this section. Hereby declare!
Note: Due to the editor, if the Chinese characters such as ", please change them to English characters" appear during code copying, otherwise the modification will fail.