Wildcards in apache virtual host? Please help if you can!
Here is the scenerio I have a couple of virtual hosts in my server all translating to one ip. Now, if I point any domain to the ip address directly, it will load the default virtual host.
ie say anyrandomdomain.com with an A record to say 222.222.222.222 (servers ip) will lead to mysite1.com
but how do you specifically seperate it to a different virtual host via wild cards such as
bucket.anyrandomdomain.com to mysite2.com instead of mysite1.com
ie bucket.. to /localtion/to/mysite2/public_html?
Because I dont know what anyrandomdomain could be, I can't make a specific file under sites-available and think my only way is add an entry to http.conf (/etc/apache2).
Can anyone help me with as to what should be done to get the results am look for? It will be greatly appreciated. Thanks!
2 Replies
@simply:
Hi,
Here is the scenerio I have a couple of virtual hosts in my server all translating to one ip. Now, if I point any domain to the ip address directly, it will load the default virtual host.
ie say anyrandomdomain.com with an A record to say 222.222.222.222 (servers ip) will lead to mysite1.com
but how do you specifically seperate it to a different virtual host via wild cards such as
bucket.anyrandomdomain.com to mysite2.com instead of mysite1.com
ie bucket.. to /localtion/to/mysite2/public_html?
Because I dont know what anyrandomdomain could be, I can't make a specific file under sites-available and think my only way is add an entry to http.conf (/etc/apache2).
Can anyone help me with as to what should be done to get the results am look for? It will be greatly appreciated. Thanks!
I believe you are looking for ServerAlias
I added two entries:
ServerAlias bucket..*
ServerAlias bucket*
Hopefully I wont need both.
For future reference for anyone with a similar problem. ServerAlias parameter under your /etc/apache2/sites-available/example.com can carry wildcards to any domain and not necessarily only subdomains to say example.com.