Redirect Nginx站点配置禁用另一站点的301重写

Redirect Nginx站点配置禁用另一站点的301重写,redirect,nginx,http-status-code-301,Redirect,Nginx,Http Status Code 301,我目前在nginx中有两个已启用的站点配置,让我们称它们为旧站点。示例和新站点。示例。没有其他站点配置处于活动状态 旧站点。示例应301重定向到新站点。示例。当前只要旧站点就可以正常工作。示例配置是单独的。添加新站点.example配置文件后,它不再重定向 oldsite.conf: server { listen 80; server_name *.old-site.example; rewrite_log on; locatio

我目前在nginx中有两个已启用的站点配置,让我们称它们为
旧站点。示例
新站点。示例
。没有其他站点配置处于活动状态

旧站点。示例
应301重定向到新站点。示例。当前只要
旧站点就可以正常工作。示例
配置是单独的。添加
新站点.example
配置文件后,它不再重定向

oldsite.conf

server {
        listen 80;
        server_name *.old-site.example;
        rewrite_log on;
        location / {
                return 301 http://www.new-site.example$request_uri;
        }

}
server {
    listen       80;
    server_name  www.new-site.example;

charset utf-8;

    location / {
        #forward to application server
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080;
    }
}
newsite.conf

server {
        listen 80;
        server_name *.old-site.example;
        rewrite_log on;
        location / {
                return 301 http://www.new-site.example$request_uri;
        }

}
server {
    listen       80;
    server_name  www.new-site.example;

charset utf-8;

    location / {
        #forward to application server
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080;
    }
}
其他配置详细信息:

  • JBoss AS7作为运行在Nginx 1.5.1之后的应用服务器

这是一个与DNS相关的错误,请大家原谅

背景:客户端的ISP设法“智能重定向”域,而不是使用DNS。他们基本上是在服务器上刮取新站点,然后通过旧域返回。我说不出话来


如果你曾经遇到过这样的问题,请先检查DNS解析,然后再猜测你的配置。

只是添加另一个说明,因为我使用firefox,我注意到一些相关的东西,firefox有时会缓存301响应,因此即使你更改设置firefox也不知道新的设置,因此,您应该清除缓存并重试,有时这就是问题所在