1

I'm trying to get subdomains working in Apache, but it won't work for me. I've already tryed Virtualhost For Wildcard Subdomain and Static Subdomain. My code for now:

<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>

The second VHost will react on vandervoorden.com and www.vandervoorden.com, but when I browse to didntexist.vandervoorden.com I recieve a page not found.

Community
  • 1
  • 1

1 Answers1

0

you need to configure your dns to return an ip for didntexist.vandervoorden.com

$ 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
mnagel
  • 6,729
  • 4
  • 31
  • 66
  • I'm sorry for the confusion, but I think this is not what I want. My intention is to catch all requests that has no existing subdomain. So, when only me.vandervoorden.com is a existing subdomain, only that one goes to ../vandervoorden.com/me and the rest of the subdomain requests (for example fsfsd.vandervoorden.com) goes to ../vandervoorden.com/other – user2582992 Jul 15 '13 at 10:27
  • 1
    then you need a wildcard on the dns level as well. the browser will not even know what server to contact without a dns record, so your apache will never be reached, so no chance to do anything on this level. this needs to be fixed on the dns level. – mnagel Jul 15 '13 at 10:28