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

后端 未结 5 502
借酒劲吻你
借酒劲吻你 2020-12-01 01:01

I want to define a variable in Apache server\'s httpd.conf configuration file.

Ex: variable static_path = C:\\codebase\\snp_static

5条回答
  •  伪装坚强ぢ
    2020-12-01 01:49

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

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

提交回复
热议问题