ngin conspires the 301 redirection setting method and the 301 redirection of the nginx subdirectory

  • 2020-05-07 20:51:50
  • OfStack

The nginx version is 1.1.19.

If the domain name is transferred from a.com to b.com and you have ownership of both domains, you can:


server{
    server_name a.com;
    return 301 $scheme://b.com$request_uri;
}

Restart the server and see if it succeeds:


curl -I a.com


nginx subdirectory 301 redirect setting method

If I want to put www. b. com/bfiles/download/turn to dx1. b. com: 81 / bfiles/download, nginx conf file website under these writing:


location ~* ^/bfiles/download/ {  
rewrite ^/bfiles/download/(.*)$ http://dx1.b.com:81/bfiles/download/$1 permanent;  
}  


Related articles: