【发布时间】:2021-04-26 14:30:29
【问题描述】:
我目前有这个域:
现在我想将所有传入的 url 重定向到:
https://api.app-2.com/content.
所以我只想替换根域(子域和目录必须继承)。这甚至可以通过 nginx 重写吗?
【问题讨论】:
标签: ubuntu nginx url-rewriting
我目前有这个域:
现在我想将所有传入的 url 重定向到:
https://api.app-2.com/content.
所以我只想替换根域(子域和目录必须继承)。这甚至可以通过 nginx 重写吗?
【问题讨论】:
标签: ubuntu nginx url-rewriting
您是否考虑过从旧域到新域的简单重定向?
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";
}
}
【讨论】: