Previously, micro-magic once shared with you many articles on Nginx tutorials (please search by yourself in the search bar on the right of this site using the keyword "Nginx"), about pseudo static, there is a centralized summary of the Nginx pseudo-static articles (transfer) of various programs, but the most common www domain name Jump problems are forgotten. For this jump, SEO is friendly, in micro-Magic's view, I prefer to display my website in the form of www.
# Pseudo-static # Nginx implements 301 redirection for www domain names
1. Redirect example.com to www.example.com
Server {
Listen 80;
Server_name example.com www.example.com;
If ($ host! = 'Www .example.com '){
Rewrite ^/(. *) $ http://www.example.com/#1 permanent;
}
}
2. Direct www.example.com to example.com
Server {
Listen 80;
Server_name example.com www.example.com;
If ($ host! = 'Example. Com '){
Rewrite ^/(. *) $ http://example.com/#1 permanent;
}
}
3. Not redirect all accesses to the specified page
Server {
Server_naaaaaaame www.aaaaaaa.com;
If ($ host! = 'Aaaaaaa. Com ')
{Rewrite ^/(. *) $ http://www.bbbbbbbbbbb.com/#1 permaaaaaaanent ;}}
If IP address access is used in the first server segment
301 redirection promotes search engine optimization
From the perspective of search engine optimization, 301 redirection is the most feasible method for URL redirection. When the domain name of a website changes, the search engine only indexes the new website and transfers the original external links under the old address to the new one, in this way, the ranking of websites will not be affected by changes in the website. Similarly, when you use the 301 permanent redirection command to direct multiple domain names to the website's primary domain, it does not have any negative impact on website rankings.