我目前拥有这个域:
https://api.app.com/content.
现在我想将所有传入的url重定向到:
https://api.app-2.com/content.
所以我只想替换根域(子域和目录必须继承(。用nginx重写,这可能吗?
您是否考虑过从旧域到新域的简单重定向?
server {
listen 80;
server_name foo.old-domain.com;
# Redirect everything to the new domain
return 301 http://foo.new-domain.com$request_uri;
}
server {
listen 80;
server_name foo.new-domain.com;
location / {
# Print the URL you're visiting
add_header Content-Type text/plain;
return 200 "URL: $uri";
}
}