wildcard in httpd conf file?

5,314

Solution 1

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

Solution 2

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:
5,314

Related videos on Youtube

Joe
Author by

Joe

Updated on September 17, 2022

Comments

  • Joe
    Joe almost 2 years

    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 :)

  • Joe
    Joe over 13 years
    would that work with full domains though? such as "ServerAlias *"?
  • Niall Donegan
    Niall Donegan over 13 years
    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.