• multiple vhosts pointing to different dirs

    From arrancurran@gmail.com@21:1/5 to All on Thu Sep 5 03:24:40 2019
    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!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli the Bearded@21:1/5 to arrancurran@gmail.com on Thu Sep 5 21:15:47 2019
    In comp.infosystems.www.servers.unix, <arrancurran@gmail.com> wrote:
    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
    snipped them) and reaches this:

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

    That's a pretty big wild card. Bet it captures everything.

    <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.

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)