server {
listen 80;
server_name docs.macrozheng.com;
rewrite "^/(.*)$" http://www.macrozheng.com/$1; #地址重写到新地址
location / {
root /usr/share/nginx/html/docs;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
//此时访问旧域名docs.macrozheng.com会直接跳转到www.macrozheng.com去。
原文:https://www.cnblogs.com/frankltf/p/12198942.html