【问题标题】:redirect the entire php url with params (apache/nginx)使用参数重定向整个 php url (apache/nginx)
【发布时间】:2015-12-28 21:19:52
【问题描述】:

1) 如何让 Apache 使用参数重定向整个 url,并使其对客户端可见,例如: 当客户来的时候:

https://domain1.com/app/index.php?device_id=WeWeWe&ordna_ver=5.0&num=+1234567890

它将他重定向到:

https://domain2.com/app/index.php?device_id=WeWeWe&ordna_ver=5.0&num=+1234567890

2) 另外,如何进行相同的重定向但对客户端不可见(从 domain2.com 打开它时,他仍然看到来自 domain1.com 的 URL)?

3) 第三,如何用 nginx 做同样的两件事(重定向)?

非常感谢您的帮助。

【问题讨论】:

    标签: apache url redirect nginx


    【解决方案1】:

    在 nginx 中,对客户端可见:

    server_name domain1.com;
    return https://domain2.com$request_uri;
    

    在 nginx 中,隐藏重定向对客户端可见:

    server_name domain1.com;
    location / {
        proxy_pass https://domain2.com;
    }
    

    如果您想确保将代理网页中提及的domain2.com 替换为domain1.com,您可能还想使用可选模块http://nginx.org/docs/http/ngx_http_sub_module.html#sub_filter(需要重新编译nginx)。

    sub_filter "https://domain1.com" "https://domain2.com";
    sub_filter_once off;
    

    【讨论】:

    • 感谢您的回答,但是如何用 Apache2 做同样的事情?
    猜你喜欢
    • 2017-01-21
    • 2017-04-29
    • 1970-01-01
    • 2021-11-03
    • 2016-11-25
    • 2014-02-18
    • 2012-11-22
    • 2014-04-07
    • 1970-01-01
    相关资源
    最近更新 更多