1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!--%hypertext -->
<!-- mod_define.html -->
<!-- Documentation for the mod_define Apache module -->
<HTML>
<HEAD>
<TITLE>Apache module mod_define</TITLE>
</HEAD>
<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
<BODY
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#000080"
ALINK="#FF0000"
>
<BLOCKQUOTE><!-- page indentation -->
<!--#include virtual="header.html" -->
<BR>
<H1 ALIGN="CENTER">Module mod_define</H1>
<H2 ALIGN="CENTER">Variable Definition For Arbitrary Directives</H2>
This module is contained in the <CODE>mod_define.c</CODE> file. It provides
the definition variables for arbitrary directives, i.e. variables which can be
expanded on any(!) directive line. It needs Extended API (EAPI). It is not
compiled into the server by default. To use <CODE>mod_define</CODE> you have
to enable the following line in the server build <CODE>Configuration</CODE>
file:
<P>
<PRE>
AddModule modules/extra/mod_define.o
</PRE>
<P>
<HR NOSHADE SIZE=1>
<H3><A NAME="Define">Define</A></H3>
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A>
<CODE>Define</CODE> <EM>variable</EM> <EM>value</EM><BR>
<A
HREF="directive-dict.html#Default"
REL="Help"
><STRONG>Default:</STRONG></A>
<EM>none</EM><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A>
server config, virtual host, directory, .htaccess<BR>
<A
HREF="directive-dict.html#Override"
REL="Help"
><STRONG>Override:</STRONG></A> none<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Extension<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_define.c<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> Apache+EAPI<BR>
<P>
The <CODE>Define</CODE> directive defines a variable which later can be
expanded with the unsafe but short construct
``<CODE>$</CODE><EM>variable</EM>'' or the safe but longer construct
``<CODE>${</CODE><EM>variable</EM><CODE>}</CODE>'' on any configuration line.
Do not intermix this with the third-party module <CODE>mod_macro</CODE>. The
<CODE>mod_define</CODE> module doesn't provide a general macro mechanism,
although one can consider variable substitutions as a special form of macros.
Because the value of to which ``<CODE>$</CODE><EM>variable</EM>'' expands has
to fit into one line. When you need macros which can span more lines, you've
to use <CODE>mod_macro</CODE>. OTOH <CODE>mod_macro</CODE> cannot be used to
expand a variable/macro on an arbitrary directive line. So, the typical use
case of <CODE>mod_define</CODE> is to make strings <EM>variable</EM> (and this
way easily changeable at one location) and not to <EM>bundle</EM> things
together (as it's the typical use case for macros).
<P>
The syntax of the expansion construct (
``<CODE>${</CODE><EM>variable</EM><CODE>}</CODE>'') follows the Perl and Shell
syntax, but can be changed via the <CODE>Define</CODE> directive, too. Four
internal variables can be used for this. The default is:
<BLOCKQUOTE>
<PRE>
Define mod_define::escape "\\"
Define mod_define::dollar "$"
Define mod_define::open "{"
Define mod_define::close "}"
</PRE>
</BLOCKQUOTE>
<P>
When you need to escape some of the expansion constructs you place the
mod_define::escape character in front of it. The default is the backslash as
in Perl or the Shell.
<P>
<STRONG>Example:</STRONG>
<BLOCKQUOTE>
<PRE>
Define master "Joe Average <joe@average.dom>"
Define docroot /usr/local/apache/htdocs
Define hostname foo
Define domainname bar.dom
Define portnumber 80
:
<VirtualHost $hostname.$domainname:$portnumber>
SetEnv SERVER_MASTER "$master"
ServerName $hostname.$domainname
ServerAlias $hostname
Port $portnumber
DocumentRoot $docroot
<Directory $docroot>
:
<Directory>
</PRE>
</BLOCKQUOTE>
<!--#include virtual="footer.html" -->
</BLOCKQUOTE><!-- page indentation -->
</BODY>
</HTML>
<!--/%hypertext -->
|