What is the correct way to use wildcard DNS?

4

I need the Apache virtualhost of my server to meet the following rule:

1- If you are domain.com or www.domain.com, then display the content at /var/www/domain.com/home

2- If it is blog.domain.com, then it displays the content in /var/www/domain.com/blog

3 - If it is a wildcard (*), that is, it is not the top two, then it displays the content in /var/www/domain.com/platform

For this to be possible I've edited my virtualhost as follows:

ServerName dominio.com
ServerAlias www.dominio.com
DocumentRoot /var/www/dominio.com/public_html/home

ServerName dominio.com
ServerAlias blog.dominio.com
DocumentRoot /var/www/dominio.com/public_html/blog

ServerName dominio.com
ServerAlias *.dominio.com
DocumentRoot /var/www/dominio.com/public_html/plataforma

And my DNS zone as follows:

@ IN A 111.111.1.111

(*) CNAME @

Doubt:

How did I do it? If not, what would it be like? Do you need to create a record in the DNS zone for www and the blog ?

    
asked by anonymous 07.09.2014 / 07:12

1 answer

0

The DNS part is correct, but the servername are in conflict, I think it should look something like this:

ServerName dominio.com
ServerAlias www.dominio.com
DocumentRoot /var/www/dominio.com/public_html/home


ServerName blog.dominio.com
ServerAlias www.blog.dominio.com
DocumentRoot /var/www/dominio.com/public_html/blog


ServerName plataforma.dominio.com
ServerAlias *.dominio.com
DocumentRoot /var/www/dominio.com/public_html/plataforma
    
07.09.2014 / 16:54