Discussion:
multiple vhosts pointing to different dirs
(too old to reply)
a***@gmail.com
2019-09-05 10:24:40 UTC
Permalink
I have a local server running (apache) such that home.test points to /www. I have a vhost pointing to /www/sites with the url sites.test. This works fine. Any folder inside /www/sites/ has the url xxx.sites.test. Now I want to add /www/dev such that any sub folders are linked to xxx.dev.test

<Directory "www/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
</Directory>

<Virtualhost *:80>
DocumentRoot "www/home/"
ServerName home.test
</Virtualhost>

<Virtualhost *:80>
VirtualDocumentRoot "www/sites/%1/_site/"
ServerName sites.test
ServerAlias *.test
</Virtualhost>

<Virtualhost *:80>
VirtualDocumentRoot "www/dev/%1/_site"
ServerName dev.test
ServerAlias *.test
</Virtualhost>

Im getting something wrong here, I would expect the above https-vhost.conf to link /www/dev/xxx to xxx.dev.test but only home.test and xxx.sites.test work.

apachectl -D DUMP_VHOSTS shows ALL three vhosts... Im so confused!
Eli the Bearded
2019-09-05 21:15:47 UTC
Permalink
Post by a***@gmail.com
I have a local server running (apache) such that home.test points to /www. I have a vhost
pointing to /www/sites with the url sites.test. This works fine. Any folder inside
/www/sites/ has the url xxx.sites.test. Now I want to add /www/dev such that any sub folders
are linked to xxx.dev.test
So an incoming request appears. What happens?
Let's say it doesn't match your two non-wildcard virtualhosts (so I
Post by a***@gmail.com
<Virtualhost *:80>
VirtualDocumentRoot "www/sites/%1/_site/"
ServerName sites.test
ServerAlias *.test
</Virtualhost>
That's a pretty big wild card. Bet it captures everything.
Post by a***@gmail.com
<Virtualhost *:80>
VirtualDocumentRoot "www/dev/%1/_site"
ServerName dev.test
ServerAlias *.test
</Virtualhost>
That's the exact same wildcard, bet it never sees anything already
caught by the first one.
Post by a***@gmail.com
Im getting something wrong here, I would expect the above https-vhost.conf to link
/www/dev/xxx to xxx.dev.test but only home.test and xxx.sites.test work.
apachectl -D DUMP_VHOSTS shows ALL three vhosts... Im so confused!
I'm pretty sure this is just "order the tests get run" and "you haven't
given any way to exclude dev from the first wildcard".

I use different top level domains for different testing environments. On
my actual production servers, I'll have .org and .net redirect to .com;
but on pre-prod you get different versions of the site visiting those.

You might want to try similar. But .dev is a real top-level-domain, so
maybe not that.

Elijah
------
recalls when .dev became a TLD and had things start breaking

Loading...