wildcard in httpd conf file?
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
Related videos on Youtube
Joe
Updated on September 17, 2022Comments
-
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 over 13 yearswould that work with full domains though? such as "ServerAlias *"?
-
Niall Donegan over 13 yearsIf 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.