1

So I have 2 configuration files.

mysite.conf

<VirtualHost *:80> ServerName www.mysite.com ServerAlias mysite.com *.mysite.com DocumentRoot /var/www/mysite/www ErrorDocument 404 /redirect.php ErrorLog logs/application/mysite.error_log CustomLog logs/application/mysite.access_log Combined </VirtualHost> 

videoupload.conf

<VirtualHost *:80> ServerName upload.mysite.com DocumentRoot /var/www/videouploader/www ErrorLog logs/application/videoupload.error_log CustomLog logs/application/videoupload.access_log Combined </VirtualHost> 

See, we have about 50 possible something.mysite.com subdomains, all that do different things, but they're all served off the same document root.

I'd like to keep *.mysite.com in there, simply because its cleaner then having the worlds longest serveralias line, plus it protects from retards trying bananananan.mysite.com or something that wouldn't work.

I've read through the apache documentation and it didn't really have anything for this senario. Anyone know how to do this?

3 Answers 3

5

Apache searches for vhost matches from top to bottom and actions the firsh match that it encounters. If you renamed videoupload.conf to 0videoupload.conf it would be read before mysite.conf and it should just work.

2
  • @GrufTech: Your other option is to put all your definitions in one file in the order you want them read. Commented Jul 15, 2011 at 15:50
  • Thats actually what I did, after I figured out apache reads top to bottom. A single file with the subdomains above the *. Commented Jul 15, 2011 at 15:52
1

I had a similar issue. The resolution was to remove the domain name from the headers of any other <VirtualHost> directive. Remove:

<VirtualHost test.blah.org:443> ServerName test.blah.org 

Replace with:

<VirtualHost *:443> ServerName test.blah.org 

Using a domain name in the header caused apache to match to that virtual host in preference to my ServerAlias static-*.blah.org under the <VirtualHost *:443> directive.

0

Multiple files are included in alphabetical order.

Shell-style (fnmatch()) wildcard characters can be used in the filename or directory parts of the path to include several files at once, in alphabetical order.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.