Forum Moderators: phranque

Message Too Old, No Replies

Multiple Dynamic Virtualhosts?

         

noyearzero

5:39 am on Oct 21, 2008 (gmt 0)

10+ Year Member



i want to be able to have a couple versions of sites going so i was going to set up urls like

v1.mysite.com
v2.mysite.com

i realize i could do this

<VirtualHost *:80>
VirtualDocumentRoot www/%1/%2+
ServerName %0
</VirtualHost>

but only if my actual folders were set up like www/v1/mysite.com and www/v2/mysite.com

my problem is v1 or v2 may be some really long odd folder names that i don't want in the url. so i really want to be able to do this

<VirtualHost *:80>
VirtualDocumentRoot www/v1 actual folder title/%2+
ServerName v1.%2+
</VirtualHost>

<VirtualHost *:80>
VirtualDocumentRoot www/v2 actual folder title/%2+
ServerName v2.%2+
</VirtualHost>

but the first VirtualDocumentRoot overrides the second even if a match can be found in the second.

so any other ideas of how to accomplish this? i was thinking maybe go with the first plan and maybe there is a way to rewrite the VirtualDocumentRoot into something else at another point? I'm not too extremely familiar with apache yet. I also really don't want to type them all out explicitly since there are so many sites.

jdMorgan

1:19 pm on Oct 22, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See the "Mass Virtual Hosting" section of the Apache URL Rewriting Guide [httpd.apache.org] for one way to do this.

Otherwise, you'll need to figure out why the first VirtualHost [httpd.apache.org] container is always matching all requests. It may do so because it is not sufficiently specific to exclude requests for the other vHosts, or because none of the other vHost containers match; The first vHost is always taken as the default "catch-all" server when no others match.

Jim

[edited by: jdMorgan at 1:20 pm (utc) on Oct. 22, 2008]