How to define a variable in apache’s httpd.conf file?

Within httpd.conf, declare your variable(s) with: Define (Preferably at the very first line)
Syntax: Define variable-name variable-value

In this manner:

#The line below creates the variable [static_path]
Define static_path C:/codebase/snp_static

You can later use this variable like so:

ServerRoot = ${static_path}
...
DocumentRoot = ${static_path}
...
<Directory ${static_path}>
...etc.

You can even combine multiple variables:

#Below, I am going to combine variables [server_space] and [static_path]
Define server_space c:/
Define static_path codebase/snp_static
...
ServerRoot = ${server_space}${static_path}
...
DocumentRoot = ${server_space}${static_path}
...
<Directory ${server_space}${static_path}>
...etc.

Documentation: http://httpd.apache.org/docs/2.4/mod/core.html#define

Leave a Comment