如何使用 nginx 重定向到新域名
为了使用 nginx 重定向到不同域名,在你的 server {...} 块中使用此代码片段:
redirect_snippet.conf
location / {
return 301 https://newdomain.com$request_uri;
}完整示例:
redirect_example.conf
server {
server_name old.domain;
listen 80;
location / {
return 301 https://techoverflow.net$request_uri;
}
}Check out similar posts by category:
Nginx
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow