Wildcards in apache virtual host? Please help if you can!

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!

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

Thanks a lot hawk7000, I rethought about ServerAlias and added an entry to mysite2.com's conf file and it seems to have worked!!

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.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct