jsheldon at MIT
Aug 11, 2012, 3:07 PM
Post #1 of 2
first name based virtual host taking precedence over all others
I'm running Apache on a Ubuntu 12.04 virtual machine.
I have multiple URL's pointing to the machine, and have been using a
Drupal multi-site instance on the server to direct users to the correct
content depending on URL. So, until just recently, I haven't needed name
based virtual host directives because I've been using Drupal.
However, we just set things up to use the Drupal instances as a staging
area, and are now hosting the content on a static site elsewhere.
So, we would like to point the top level URL's (home pages) ONLY to the
new static sites, and keep deeper links pointing to the original server.
In other words, the desired behavior is that:
http://one.example.machine.org/ -> http://another.machine.org/one
http://two.example.machine.org/ -> http://another.machine.org/two
And URLs like:
don't get redirected.
So, I set up two name based virtual hosts, one each for
one.example.machine.org and two.example.machine.org, and I used a
RedirectMatch instruction matching ^/$ and pointing that to the
corresponding new URL.
This almost worked, but didn't work for some reason. The observed behavior
is that ALL URL's coming in to the virtual machine get redirected to the
new URL for the first virtual host, and the second (and any subsequent, as
per some testing) virtual host information, including the RedirectMatch
Just for elimination purposes, I did test to see if Drupal multisite was
somehow acting as the culprit. It does not appear to be the case, as I
tried to point different name based VH's to different document roots. I
saw similar behavior, in that every URL going to that machine ended up at
the new doc root.
For further reference, the relevant (at least I think it's the relevant)
part of the /etc/apache2/apache2.conf file that did NOT work:
allow from all
RedirectMatch ^/$ "http://another.example.machine/one"
allow from all
RedirectMatch ^/$ "http://another.example.machine/two"
I've been banging my head against this for a while, and can't solve it
yet, so any help you can provide will be greatly appreciated.
To unsubscribe, e-mail: users-unsubscribe [at] httpd
For additional commands, e-mail: users-help [at] httpd