On Tue, May 3, 2022 at 5:44 PM Yann Ylavic <[email protected]> wrote:
>
> On Mon, May 2, 2022 at 8:24 AM Ivan Ionut <[email protected]> wrote:
> >
> > I'm trying to set a virtual host on apache2 with this configuration.
> >
> > <VirtualHost *:80>
> > ServerName mysite.com
> > ServerAlias www.mysite.com
> >
> > <If "-R '192.168.1.0/24'">
> > Define directory_path /srv/http/mysite
> > </If>
> > <Else>
> > Define directory_path /srv/http/under_construction
> > </Else>
> >
> > DocumentRoot ${directory_path}
> >
> > <Directory ${directory_path}>
> > Require all granted
> > </Directory>
> > </VirtualHost>
> >
> > The problem is that the If directive does not match when I access it from
> > that lan.
>
> Possibly something like this could work:
>
> Define directory_path_mysite "/srv/http/mysite"
> Define directory_path_under_construction "/srv/http/under_construction"
> <VirtualHost *:80>
> <If "-R '192.168.1.0/24'">
> DocumentRoot "${directory_path_mysite}"
> <Else>
> DocumentRoot "$(directory_path_under_construction}"
> </If>
But DocumentRoot might not be allowed in an <If section..
> <Directory "${directory_path_mysite}">
> Require all granted
> </Directory>
> <Directory "${directory_path_under_construction}">
> Require all granted
> </Directory>
> </VirtualHost>
>
> Both DocumentRoots would be initialized at startup (when Defines are
> evaluated, the <Directory paths must be known then), while the
> DocumentRoot used at runtime will be determined based on the <If
> still.
>
>
> Regards;
> Yann.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]