【问题标题】:IP Address gets redirected to Sub-domain instead of DomainIP 地址被重定向到子域而不是域
【发布时间】:2013-11-02 17:19:54
【问题描述】:

我有一个域,可以考虑 example.com 和子域 blog.example.com 两者都在同一个 VPS 中运行,使用 Nginx 提供的静态 IP,都在端口 80 上侦听。

每当我在浏览器中输入我的 IP 地址时添加我的子域之前,都会提供默认域(即 example.com)。但是添加博客子域后,输入IP地址重定向到blog.example.com。默认情况下如何将其重定向到 example.com?为 blog.example.com 使用不同的端口号可以解决这个问题吗?

【问题讨论】:

    标签: nginx dns subdomain


    【解决方案1】:

    在虚拟主机文件中,确保它被标记为default_server,例如:

    server {
        server_name example.com;
        listen 80 default_server;
        # rest of the config
    }
    

    还要确保没有其他 conf 文件也标记为 default_server

    【讨论】:

      猜你喜欢
      • 2018-01-05
      • 2020-04-07
      • 2021-11-23
      • 2021-03-25
      • 2021-08-27
      • 1970-01-01
      • 2016-01-09
      • 2014-05-20
      相关资源
      最近更新 更多