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

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

        ServerName mysite.com
        ServerAlias www.mysite.com
        DocumentRoot /home/folder

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

2 Answers 2

up vote 2 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

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.


share|improve this answer

Your Answer


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.