简体   繁体   English

Apache 2.2禁用未配置的子域

[英]Apache 2.2 disable unconfigured subdomains

There is a webserver which has example.com, www.example.com, my.example.com, shop.example.com, static.example.com. 有一个网络服务器,其中包含example.com,www.example.com,my.example.com,shop.example.com,static.example.com。 All sites except www.example.com is on https. 除www.example.com以外的所有网站均位于https上。 My problem is when I type randomstring.example.com -> shop.example.com gets served. 我的问题是当我输入randomstring.example.com-> shop.example.com时得到了服务。 But I want nothing to be served. 但是我什么也不想得到。 For example mail.google.com is a valid subdomain. 例如,mail.google.com是有效的子域。 if you type johndoe.google.com you see "This webpage is not available". 如果您键入johndoe.google.com,则会看到“此网页不可用”。 How to achieve this via Vhost/.htaccess file. 如何通过Vhost / .htaccess文件实现此目的。

  1. It's not the part of apache. 这不是Apache的一部分。 You should disallow DNS resolving for subdomains like *.example.com. 您应该禁止对* .example.com之类的子域进行DNS解析。 or 要么
  2. If you don't have access to the DNS server - you can create a virtualhost with blank index page and put this virtualhost directive on top of the all virtualhosts. 如果您无权访问DNS服务器,则可以创建带有空白索引页面的虚拟主机,并将此虚拟主机指令放在所有虚拟主机的顶部。 It shouldn't be same as google's behavior (they are using 1st way), but at least you can protect shop.example.com visiting from randomstring.example.com 它不应该与Google的行为(他们使用的是第一种方式)相同,但是至少您可以保护shop.example.com免受randomstring.example.com的访问

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM