【问题标题】:How to redirect a specific url to a different domain (Nginx)如何将特定的 url 重定向到不同的域(Nginx)
【发布时间】:2019-04-18 17:46:48
【问题描述】:

我要重定向https://example.com/wp-json/wp/v2/

https://anotherDomain.com/wp-json/wp/v2/

我试过了

rewrite ^(/wp-json/wp/v2/.*) $scheme://anotherDomain.com/wp-json/wp/v2/ break;

它重定向到https://anotherDomain.com/wp-json/wp/v2/ 然后不断重定向,重定向循环

【问题讨论】:

    标签: url nginx redirect nginx-reverse-proxy


    【解决方案1】:

    尝试$scheme://anotherDomain.com/wp-json/wp/v2/$request_uri,其中$request_uri 是包含参数的完整URI。

    作为一个选项,您可以将 (301) 重定向到新域:

    server {
        listen 80;
        listen 443 ssl;
        server_name www.old-name.com;
        return 301 $scheme://www.new-name.com$request_uri;
    }
    

    看看this

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-11-03
    • 1970-01-01
    • 2017-06-15
    • 2014-04-06
    • 2015-10-19
    • 2014-03-21
    • 2018-02-15
    • 2017-02-20
    相关资源
    最近更新 更多