Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Here is an example httpd config I'm currently using:

<VirtualHost 123.123.123.123:80>
        ServerName mysite.com
        ServerAlias www.mysite.com
        DocumentRoot /home/folder
</VirtualHost>

I'm wondering, is it possible to have a wildcard for the ServerName & ServerAlias variable?

Reason for asking is I have some software that is shared among multiple URL's all controlled in a CMS and it's kind of a pain to add new domains via ssh everytimee. And before someone points out a security hole, the software does check the current URL before doing any webpages :)

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Yes, replace ServerAlias www.mysite.com with ServerAlias *.mysite.com and you should be good to go.

share|improve this answer
    
would that work with full domains though? such as "ServerAlias *"? –  Joe Jan 18 '11 at 3:28
    
If you need that, just make it the first virtual host on the system as Sameer has indicated below. The other option is to dedicate an ip to it and have no NameVirtualHost setup on that ip. –  Niall Donegan Jan 18 '11 at 10:24
add comment

Make this virtual host entry the first entry. By default if there is no match then apache uses the first entry as the default entry.

Check under the "Main host goes away" title.

http://httpd.apache.org/docs/2.0/vhosts/name-based.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.