You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by sebb <se...@gmail.com> on 2018/05/10 13:56:34 UTC
[users@httpd] Getting hostname from FQDN as variable in config file
Is it possible the access the hostname part of a FQDN in a config file?
For example, suppose the config has the following condition:
<If "-d '/var/test/%{HTTP_HOST}'">
This might resolve to a directory such as:
/var/test/NAME.example.com
Is there a way to resolve just the initial part of the host, i.e. NAME?
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Getting hostname from FQDN as variable in config file
Posted by sebb <se...@gmail.com>.
On 10 May 2018 at 15:09, Eric Covener <co...@gmail.com> wrote:
> On Thu, May 10, 2018 at 9:56 AM, sebb <se...@gmail.com> wrote:
>> Is it possible the access the hostname part of a FQDN in a config file?
>>
>> For example, suppose the config has the following condition:
>>
>> <If "-d '/var/test/%{HTTP_HOST}'">
>>
>> This might resolve to a directory such as:
>>
>> /var/test/NAME.example.com
>>
>> Is there a way to resolve just the initial part of the host, i.e. NAME?
>
> I think there are some quirks that make this a little unruly. But you
> could extract it with a simple SetEnvIf in advance than look at the
> set environment variable instead:
Thanks!
> SetEnvIf Host ^([^.]+) HOST_UNQUALIFIED=$1
>
> Then use reqenv('HOST_UNQUALIFIED') instead of the variable.
Turns one needs to use a different syntax:
<If "-d '/var/test/%{reqenv:HTTP_UNQUALIFIED}'">
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Getting hostname from FQDN as variable in config file
Posted by Eric Covener <co...@gmail.com>.
On Thu, May 10, 2018 at 9:56 AM, sebb <se...@gmail.com> wrote:
> Is it possible the access the hostname part of a FQDN in a config file?
>
> For example, suppose the config has the following condition:
>
> <If "-d '/var/test/%{HTTP_HOST}'">
>
> This might resolve to a directory such as:
>
> /var/test/NAME.example.com
>
> Is there a way to resolve just the initial part of the host, i.e. NAME?
I think there are some quirks that make this a little unruly. But you
could extract it with a simple SetEnvIf in advance than look at the
set environment variable instead:
SetEnvIf Host ^([^.]+) HOST_UNQUALIFIED=$1
Then use reqenv('HOST_UNQUALIFIED') instead of the variable.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org