We often access a website. What if we set the mgcrazy.com domain name to automatically jump to www.mgcrazy.com when users access it? I have found a lot of information on the Internet, but none of them can solve the problem! Here are my solutions! For your learning and reference!
First, define mgcrazy.com and www.mgcrazy.com in your domain name management to point to your host IP address. We can use the nslookup command to test: directly enter nslookup mgcrazy.com and nslookup www.mgcrazy.com to have a record pointing to the ip address.
Second, we can configure rewrite Rules in nginx. Open the nginx. conf file and find your server configuration section:
Server
{
Listen 80;
Server_name www.mgcrazy.com mgcrazy.com;
If ($ host! = 'Www .mgcrazy.com '){
Rewrite ^/(. *) $ http://www.mgcrazy.com/#1 permanent;
}
In this way, you can directly access the www.mgcrazy.com directly redirected to mgcrazy.com. That is, let the domain name without www jump to the domain name with www.
3. We can redirect multiple second-level domain names and third-level domain names at will, or let them all jump to the chinaapp.sinaapp.com domain name. Just add the following statement:
Server
{
Listen 80;
Server_name blog.mgcrazy.com wgkgood.gicp.net;
If ($ host = 'wgkgood .gicp.net '){
Rewrite ^/(. *) $ http://chinaapp.sinaapp.com/#1 permanent;
}
Redirect another free second-level domain name wgkgood.gicp.net to my blog http://chinaapp.sinaapp.com;
This will not affect the search engine after the second-level domain name is abandoned. Seo is very helpful.
For more nginx rules, join us! Mutual Improvement! I always believe that the value of a person is not what he has achieved, but what he has contributed to others!