HomeOracle Page 2 - Understanding Directives and More with the Oracle HTTP Server
What Are Block Directives? - Oracle
In this fourth article in a five-part series, you'll learn about block directives, virtual hosting, and more as they apply to the Oracle HTTP Server (OHS). It is excerpted from chapter five of the book Oracle 10g Application Server Exam Guide, written by Sam Alapati (McGraw-Hill, 2006; ISBN: 0072262710).
A block directive specifies conditions under which the directive will take effect. Thus, block directives aren't scope based, but rather depend on whether the HTTP Server will take its directives into account when starting up, based on some condition holding true or false. You can use block directives to limit directives to work only on certain virtual hosts, directories, or files. There are two block directives: <IfModule> and <IfDefine>.
You use the <IfModule> directive to mark those directives that are processed only if a certain module is present and is available in the OHS server. The stated module can be made available to OHS in either of two ways. It can be statically compiled into the OHS server, or you must make the module dynamically available by compiling the module and placing a LoadModule line in the httpd.conf file. The LoadModule line must appear before the <IfModule> directive.
Here’s an example using the <IfModule> directive that comes into effect only for the mod_user_dir.c module:
Any URL whose path starts with a tilde would be mapped to UserDir, provided the mod_userdir.c module exists. Otherwise, the <IfModule> directive has no effect.
As you're probably aware, in the Apache HyperText Transfer Protocol (HTTP) server program, the httpd daemon, when run as a standalone process, creates child processes or threads to handle user service requests. You normally don't invoke the httpd daemon directly, but rather do so through using the apachectl utility on Apache systems, and the opmnctl utility in Oracle HTTP Server.
The directives within an <IfDefine> section are processed only if the enclosed test is evaluated to be true; otherwise, everything between the two <IfDefine> section markers is ignored. The <IfDefine> directive uses the parameter-name argument given on the httpd command line via the -D parameter. Note that the <IfDefine>directive is thus used for conditionally processing directives, based on the evaluation of the conditions that prevail when the OHS server is started. OHS will apply the directives within the <IfDefine> directive only if the stated parameter is defined on the httpd command line. In the following example, requests will be redirected to alternative sites only if you start the OHS server with the httpd --DclosedForNow option.
By using the parameter-name specification, you can reverse the test and process directives within the <IfDefine> sections if the parameter name isn't defined.
Note that containers can't include other containers, with the exception of the Limit directive and the Files container. You can include a Files container in a Directory container. You can place any directive inside a Limit or LimitExcept container, as long as the Limit or LimitExcept directive is placed within a container that conforms to these directives. You can include all the other container types inside a <VirtualHost> container.