HOWTO - Wildcard in apache and bind

From wiki.morphey.org

Jump to: navigation, search

A lot of times find us in front of the situation to have a standard configuration both of bind and of Apache for "to program" the acceptance of wildcard in the subdomainses of the principal domainses.

For example, if I want that the subdomains mysub.domain.com aims to domain.com, but also all how much the *. domain.com aim to domain.com in dynamic way without, therefore, to have a configuration for every subdomains.

This configuration is thick used for bases multiblog type wordpress.

Following the line to be added to bind to accept the wildcard:

 
*.domain.com.    IN      A       192.168.1.1
 

It will become therefore:

 
domain.com. 86400     IN      SOA     domain.com. hostmaster.domain.com. (
                                        2005100804      ; Serial YYYYMMDDXX
                                        10800           ; Refresh
                                        3600            ; Retry
                                        3600000         ; Expire
                                        86400 )         ; minimum
                        IN      NS      ns1.domain.com.
                        IN      NS      ns2.domain.com.
                        IN      MX      10      mail.domain.com.
                        IN      A       192.168.1.1
mail                    IN      A       192.168.1.1
ns1                     IN      A       192.168.1.1
ns2                     IN      A       10.0.0.2
*.domain.com.		IN      A       192.168.1.1
 

For Apache, we can add in the virtualhost this line:

 
 
        ServerName  www.domain.com
	ServerAlias *.domain.com
 
        DirectoryIndex index.html 
        DocumentRoot /home/www/www.domain.com/htdocs
 
	....
 

For Apache, we can add in the virtualhost this line:

Et voilĂ , the games are made:)

Personal tools