【问题标题】:Force nginx to redirect one domain to another while keeping URL structure?强制 nginx 在保持 URL 结构的同时将一个域重定向到另一个域?
【发布时间】:2017-05-31 20:31:37
【问题描述】:

我正在寻找一种将 exampledomain.com 重定向到 exampledomain2.com 的方法,同时还保持 URL 结构。例如:

http://exampledomain.com/forum/post1.php

会重定向到

http://exampledomain2.com/forum/post1.php

有人对此有简单的解决方案吗?提前致谢!

【问题讨论】:

    标签: redirect nginx url-redirection http-redirect


    【解决方案1】:

    应该直截了当:

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

    请参阅此blog 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-13
      • 2020-05-28
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      • 1970-01-01
      • 2011-06-17
      • 2017-05-18
      相关资源
      最近更新 更多