Apache config IF conditional

Issues related to applications and software problems
Post Reply
Boyd.ako
Posts: 46
Joined: 2016/06/22 08:49:07
Location: Honolulu, HI
Contact:

Apache config IF conditional

Post by Boyd.ako » 2019/06/27 23:30:07

Anybody know where I can find detailed docs on the Apache IF conditional used with virtual hosts? More specifically, a set of variables to in the conditional. To speak BASH, I'd like to setup something like this...

Code: Select all

if [ "$access" == "denied" ]; then
     if [ "$ip" == "10.0.0.*" ]; then
           Errordocument 403 https://www.google.com
     elif [ "$ip" == "192.168.0.*" ]; then
          Errordocument 403 https://www.yahoo.com
     else
          Errordocument 403 https://www.msn.com
     fi
fi
My noob level: LPIC-2, Sec+ CE, Linux+
https://boydhanaleiako.me

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Apache config IF conditional

Post by hunter86_bg » 2019/06/28 10:58:20

Just convert your bash to cgi script (careful with SELINUX ) and pass that to ErrorDocument.

As I have never done it before , I can't give an example.

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: Apache config IF conditional

Post by pjsr2 » 2019/06/28 11:24:00

The use of variables and expressions in the Apache configuration files is explained in https://httpd.apache.org/docs/2.4/expr.html

Post Reply