You can't do it in the DNS - a wildcard will match one or more DNS labels.
You may be able to do it in the Apache server, perhaps by using mod_rewrite
to match on the supplied hostname and returning a 404 error if the hostname is invalid.
Domanda
I want to know how to set a wildcard DNS for only first level subdomain, example:
user.example.com // valid
www.user.example.com // invalid
I have my BIND zone domain configured like this:
; example.com
$TTL 86400
@ IN SOA ns.example.com. domain.example.com. (
2014021001 ; Serial
28800 ; Refresh
1800 ; Retry
604800 ; Expire - 1 week
86400 ) ; Minimum
IN NS ns
IN NS ns1
ns IN A 1.2.3.4 ; An IP
ns1 IN A 1.2.3.4 ; An IP
@ IN A 1.2.3.4 ; An IP
*.example.com IN A 1.2.3.4 ; An IP
www IN A 1.2.3.4 ; An IP
@ IN TXT "v=spf1 a mx -all"
And my Apache virtual host config is like this:
<VirtualHost 1.2.3.4:80>
ServerAdmin domain@example.com
DocumentRoot /var/www/html/example.com
ServerAlias www.example.com
ServerName example.com
ErrorLog logs/example.com-error_log
CustomLog logs/example.com-access_log common
</VirtualHost>
<VirtualHost 1.2.3.4:80>
ServerAdmin domain@example.com
DocumentRoot /var/www/html/apps.example.com
ServerAlias *.example.com
ServerName apps.example.com
ErrorLog logs/apps.example.com-error_log
CustomLog logs/apps.example.com-access_log common
</VirtualHost>
Please help!
Soluzione
You can't do it in the DNS - a wildcard will match one or more DNS labels.
You may be able to do it in the Apache server, perhaps by using mod_rewrite
to match on the supplied hostname and returning a 404 error if the hostname is invalid.