将子文件夹重写到子域而不使用 nginx 重定向
Rewriting subfolder to subdomain without redirect with nginx
我希望在不重定向用户的情况下将对 http://example.com/products/some-variable
的请求重写为 http://catalog.example.com/some-variable
。换句话说,URL 不应该改变。
我找到了一个类似的例子here,但我似乎无法弄清楚如何做相反的事情。
提前致谢!
我想你的情况应该是这样的:
server {
listen 80;
server_name example.com;
location ~ ^/products/(.*)$ {
proxy_pass http://catalog.example.com/;
}
}
这是包含 proxy_pass
个示例的文章:
我希望在不重定向用户的情况下将对 http://example.com/products/some-variable
的请求重写为 http://catalog.example.com/some-variable
。换句话说,URL 不应该改变。
我找到了一个类似的例子here,但我似乎无法弄清楚如何做相反的事情。
提前致谢!
我想你的情况应该是这样的:
server {
listen 80;
server_name example.com;
location ~ ^/products/(.*)$ {
proxy_pass http://catalog.example.com/;
}
}
这是包含 proxy_pass
个示例的文章: