</contextlist>
<usage>
- <p>In its one parameter form, <directive>Define</directive> is equivalent
- to passing the <code>-D</code> argument to <program>httpd</program>. It
- can be used to toggle the use of
- <directive module="core" type="section">IfDefine</directive> sections
- without needing to alter <code>-D</code> arguments in any startup
- scripts.</p>
+ <p>In its one parameter form, <directive>Define</directive> is
+ equivalent to passing the <code>-D</code> argument to
+ <program>httpd</program>. It can be used to toggle the use of
+ <directive module="core" type="section">IfDefine</directive>
+ sections without needing to alter <code>-D</code> arguments in any
+ startup scripts.</p>
<p>In addition to that, if the second parameter is given, a config variable
is set to this value. The variable can be used in the configuration using
</usage>
</directivesynopsis>
+<directivesynopsis type="section">
+<name>IfDirective</name>
+<description>Encloses directives that are processed conditional on the
+presence or absence of a specific directive</description>
+<syntax><IfDirective [!]<var>directive-name</var>> ...
+ </IfDirective></syntax>
+<contextlist><context>server config</context><context>virtual host</context>
+<context>directory</context><context>.htaccess</context>
+</contextlist>
+<override>All</override>
+
+<usage>
+ <p>The <code><IfDirective <var>test</var>>...</IfDirective></code>
+ section is used to mark directives that are conditional on the presence of
+ a specific directive. The directives within an <directive type="section"
+ >IfDirective</directive> section are only processed if the <var>test</var>
+ is true. If <var>test</var> is false, everything between the start and
+ end markers is ignored.</p>
+
+ <p>The <var>test</var> in the <directive type="section"
+ >IfDirective</directive> section can be one of two forms:</p>
+
+ <ul>
+ <li><var>directive-name</var></li>
+
+ <li>!<var>directive-name</var></li>
+ </ul>
+
+ <p>In the former case, the directives between the start and end
+ markers are only processed if a directive of the given name is
+ available at the time of processing. The second format reverses the test,
+ and only processes the directives if the <var>directive-name</var> is
+ <strong>not</strong> defined.</p>
+
+ <note>This section should only be used if you need to have one
+ configuration file that works across multiple versions of
+ <program>httpd</program>, regardless of whether a particular
+ directive is available. In normal operation, directives need not
+ be placed in <directive type="section">IfDirective</directive>
+ sections.</note>
+</usage>
+<seealso><directive module="core" type="section">IfSection</directive></seealso>
+</directivesynopsis>
+
+<directivesynopsis type="section">
+<name>IfSection</name>
+<description>Encloses directives that are processed conditional on the
+presence or absence of a specific section directive</description>
+<syntax><IfSection [!]<var>section-name</var>> ...
+ </IfSection></syntax>
+<contextlist><context>server config</context><context>virtual host</context>
+<context>directory</context><context>.htaccess</context>
+</contextlist>
+<override>All</override>
+
+<usage>
+ <p>The <code><IfSection
+ <var>test</var>>...</IfSection></code> section is used
+ to mark directives that are conditional on the presence of a
+ specific section directive. A section directive is any directive
+ such as <directive type="section">virtualhost</directive> which
+ encloses other directives, and has a directive name with a leading
+ "<". The sec
+
+ The directives within an <directive type="section"
+ >IfSection</directive> section are only processed if the <var>test</var>
+ is true. If <var>test</var> is false, everything between the start and
+ end markers is ignored.</p>
+
+ <p>The <var>section-name</var> specified must not include the
+ leading "<". The <var>test</var> in the <directive
+ type="section">IfSection</directive> section can be one of two
+ forms:</p>
+
+ <ul>
+ <li><var>section-name</var></li>
+ <li>!<var>section-name</var></li>
+ </ul>
+
+ <p>In the former case, the directives between the start and
+ end markers are only processed if a section directive of the given
+ name is available at the time of processing. The second format
+ reverses the test, and only processes the directives if the
+ <var>section-name</var> is <strong>not</strong> defined.</p>
+
+ <p>For example:</p>
+
+ <highlight language="config">
+<IfSection VirtualHost>
+ ...
+</IfSection>
+ </highlight>
+
+ <note>This section should only be used if you need to have one
+ configuration file that works across multiple versions of <program>httpd</program>,
+ regardless of whether a particular section directive is
+ available. In normal operation, directives need not be placed in
+ <directive type="section">IfSection</directive> sections.</note>
+</usage>
+<seealso><directive module="core" type="section">IfDirective</directive></seealso>
+</directivesynopsis>
+
<directivesynopsis>
<name>Include</name>
<description>Includes other configuration files from within
return (apr_stat(&sb, relative, 0, cmd->pool) == APR_SUCCESS);
}
+static int test_ifdirective_section(cmd_parms *cmd, const char *arg)
+{
+ return ap_exists_directive(cmd->temp_pool, arg);
+}
+
+static int test_ifsection_section(cmd_parms *cmd, const char *arg)
+{
+ const char *name = apr_pstrcat(cmd->temp_pool, "<", arg, NULL);
+ return ap_exists_directive(cmd->temp_pool, name);
+}
+
/* httpd.conf commands... beginning with the <VirtualHost> business */
static const char *virtualhost_section(cmd_parms *cmd, void *dummy,
AP_INIT_TAKE1("<IfFile", start_cond_section, (void *)test_iffile_section,
EXEC_ON_READ | OR_ALL,
"Container for directives based on existence of files on disk"),
+AP_INIT_TAKE1("<IfDirective", start_cond_section, (void *)test_ifdirective_section,
+ EXEC_ON_READ | OR_ALL,
+ "Container for directives based on existence of named directive"),
+AP_INIT_TAKE1("<IfSection", start_cond_section, (void *)test_ifsection_section,
+ EXEC_ON_READ | OR_ALL,
+ "Container for directives based on existence of named section"),
AP_INIT_RAW_ARGS("<DirectoryMatch", dirsection, (void*)1, RSRC_CONF,
"Container for directives affecting resources located in the "
"specified directories"),