【问题标题】:Apache Vhost subdomain wildcardApache Vhost 子域通配符
【发布时间】:2013-07-13 03:50:35
【问题描述】:

我正在尝试让子域在 Apache 中运行,但它对我不起作用。我已经尝试过Virtualhost For Wildcard Subdomain and Static Subdomain。 我现在的代码:

<VirtualHost *:80>
DocumentRoot /Bestanden/webserver/vandervoorden.com/other
ServerName other.vandervoorden.com
ServerAlias *.vandervoorden.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /Bestanden/webserver/vandervoorden.com
<Directory "/Bestanden/webserver/vandervoorden.com">
allow from all
Options +Indexes
</Directory>
ServerName vandervoorden.com
</VirtualHost>

第二个 VHost 将对 vandervoorden.com 和 www.vandervoorden.com 做出反应,但是当我浏览到 didtexist.vandervoorden.com 时,我收到一个未找到的页面。

【问题讨论】:

    标签: apache subdomain virtualhost


    【解决方案1】:

    您需要配置您的 dns 以返回 didtexist.vandervoorden.com 的 ip

    $ dig didntexist.vandervoorden.com A
    
    ; <<>> DiG 9.8.3-P1 <<>> didntexist.vandervoorden.com A
    ;; global options: +cmd
    ;; Got answer:
    ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 61164
    ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
    
    ;; QUESTION SECTION:
    ;didntexist.vandervoorden.com.  IN  A
    
    ;; AUTHORITY SECTION:
    vandervoorden.com.  14400   IN  SOA nszero1.axc.nl. hostmaster.vandervoorden.com. 2013071200 14400 3600 1209600 86400
    
    ;; Query time: 169 msec
    ;; SERVER: 129.13.64.5#53(129.13.64.5)
    ;; WHEN: Mon Jul 15 12:07:03 2013
    ;; MSG SIZE  rcvd: 107
    

    【讨论】:

    • 我很抱歉造成混乱,但我认为这不是我想要的。我的目的是捕获所有没有现有子域的请求。因此,当只有 me.vandervoorden.com 是现有子域时,只有那个转到 ../vandervoorden.com/me,其余子域请求(例如 fsfsd.vandervoorden.com)转到 ../vandervoorden。 com/其他
    • 那么您还需要在 dns 级别使用通配符。如果没有 dns 记录,浏览器甚至不知道要联系哪个服务器,因此永远无法访问您的 apache,因此在此级别上没有机会做任何事情。这需要在 dns 级别进行修复。
    猜你喜欢
    • 2020-04-17
    • 2017-11-02
    • 2014-02-22
    • 2019-11-12
    • 2015-08-26
    • 2020-03-30
    • 2012-11-14
    • 2014-12-28
    • 2018-05-08
    相关资源
    最近更新 更多