ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaie_5.4.0.1/rzaiemod_setenvif.htm

328 lines
20 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="topic" />
<meta name="DC.Title" content="Module mod_setenvif" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2002,2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2002,2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rzaiemod_setenvif" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Module mod_setenvif</title>
</head>
<body id="rzaiemod_setenvif"><a name="rzaiemod_setenvif"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<!--Java sync-link--><h1 class="topictitle1">Module mod_setenvif</h1>
<div><div class="important"><span class="importanttitle">Important:</span> Information
for this topic supports the latest PTF levels for HTTP Server for i5/OS .
It is recommended that you install the latest PTFs to upgrade to the latest
level of the HTTP Server for i5/OS. Some of the topics documented here are
not available prior to this update. See <a href="http://www-03.ibm.com/servers/eserver/iseries/software/http/services/service.html" target="_blank">http://www.ibm.com/servers/eserver/iseries/software/http/services/service.htm</a> <img src="www.gif" alt="Link outside Information Center" /> for more information. </div>
<p><strong>Summary</strong></p>
<p>The mod_setenvif module allows you to set environment variables if different
aspects of the request match regular expressions that you specify. These variables
can be used by other parts of the server to make decisions about actions to
be taken. </p>
<p>The directives are considered in the order they appear in the configuration.
So more complex sequences can be used, such as this example, which sets Netscape
if the browser is Mozilla but not MSIE.</p>
<pre class="block">BrowserMatch ^Mozilla netscape
BrowserMatch MSIE !netscape</pre>
<p><strong>Directives</strong></p>
<ul><li><a href="#browsermatch">BrowserMatch</a></li>
<li><a href="#browsermatchnocase">BrowserMatchNoCase</a></li>
<li><a href="#setenvIf">SetEnvIf</a></li>
<li><a href="#setenvifnocase">SetEnvIfNoCase</a> </li>
</ul>
</div>
<div class="hr" id="browsermatch"><a name="browsermatch"><!-- --></a><h2 class="topictitle2">BrowserMatch</h2>
<div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="void" border="0" rules="none"><tbody><tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Module">Module</a></strong>: mod_setenvif </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Syntax">Syntax</a></strong>: BrowserMatch <em>regex envar[=value] [...] </em></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Default">Default</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Context">Context</a></strong>: <span id="browsermatch__browsermatch_context"><a name="browsermatch__browsermatch_context"><!-- --></a>server config,
virtual host, directory, .htaccess </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Override">Override</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Origin">Origin</a></strong>: <span id="browsermatch__browsermatch_origin"><a name="browsermatch__browsermatch_origin"><!-- --></a>Apache</span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Example">Example</a></strong>: BrowserMatch ^Mozilla forms jpeg=yes browser=netscape </td>
</tr>
</tbody>
</table>
</div>
<p>BrowserMatch defines environment variables based on the User-Agent HTTP
request header field. The first argument should be a POSIX.2 extended regular
expression (similar to an egrep-style regex). The rest of the arguments give
the names of variables to set, and optional values to which they should be
set. These take the form of the following:</p>
<ul><li>varname</li>
<li>!varname</li>
<li>varname=value</li>
</ul>
<p>See <a href="rzaieenvvar.htm">Environment variables on HTTP Server</a> for more information.</p>
<p>In the first form, the value will be set to "1". The second will remove
the given variable if already defined, and the third will set the variable
to the value given by value. If a User-Agent string matches more than one
entry, they will be merged. Entries are processed in the order in which they
appear, and later entries can override earlier ones. For example:</p>
<pre class="block">BrowserMatch ^Mozilla forms jpeg=yes browser=netscape
BrowserMatch ^Mozilla/[2-3]" tables agif frames javascript
BrowserMatch MSIE !javascript</pre>
<p>In the above example, if the User-Agent field is Mozilla, the environment
variables forms, jpeg=yes and browser=netscape will be set. If the request
is Mozilla/2 or Mozilla/3, then in addition to the environment variables on
the first BrowserMatch directive, the variables tables, agif, frames and javascript
will be set. </p>
<div class="note"><span class="notetitle">Note:</span> The regular expression string is case-sensitive. For case-insensitive
matching, see <a href="#browsermatchnocase">BrowserMatchNoCase</a>. BrowserMatch and <a href="#browsermatchnocase">BrowserMatchNoCase</a> are special cases of <a href="#setenvIf">SetEnvIf</a> and <a href="#setenvifnocase">SetEnvIfNoCase</a>. The following two lines have the same effect: </div>
<pre class="block">BrowserMatchNoCase Robot is_a_robot
SetEnvIfNoCase User-Agent Robot is_a_robot</pre>
<dl class="block"><dt class="dlterm"><strong>Parameter One</strong>: <em>regex </em></dt>
<dd><ul><li>The <em>regex</em> parameter is a case-sensitive POSIX.2 extended regular
expression. This gives the user the ability to select variants on the User-Agent
field, such as using some wildcarding to group versions of a client browser.
See <a href="rzaieenvvar.htm">Environment variables on HTTP Server</a> for more information.</li>
</ul>
</dd>
</dl>
<dl class="block"><dt class="dlterm"><strong>Parameter Two</strong>: <em>envvar[=value] </em></dt>
<dd><ul><li>The <em>envvar[=value]</em> parameter gives the names of the variables to
set and, optional, values to which they should be set. The case is preserved
when lowercase characters are specified. Valid values include all EBCDIC characters.
The value must be enclosed in quotation marks if it contains any non-alphanumeric
character or blanks. </li>
</ul>
</dd>
</dl>
</div>
</div>
<div class="hr" id="browsermatchnocase"><a name="browsermatchnocase"><!-- --></a><h2 class="topictitle2">BrowserMatchNoCase</h2>
<div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="void" border="0" rules="none"><tbody><tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Module">Module</a></strong>: mod_setenvif </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Syntax">Syntax</a></strong>: BrowserMatchNoCase <em>regex envar[=value]
[...] </em></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Default">Default</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Context">Context</a></strong>: <span id="browsermatchnocase__browsermatchnocase_context"><a name="browsermatchnocase__browsermatchnocase_context"><!-- --></a>server
config, virtual host, directory, .htaccess </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Override">Override</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Origin">Origin</a></strong>: <span id="browsermatchnocase__browsermatchnocase_origin"><a name="browsermatchnocase__browsermatchnocase_origin"><!-- --></a>Apache </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Example">Example</a></strong>: BrowserMatchNoCase ibm platform=ibm </td>
</tr>
</tbody>
</table>
</div>
<p>BrowserMatchNoCase is semantically identical to <a href="#browsermatch">BrowserMatch</a>.
However, it provides for case-insensitive matching. For example: </p>
<pre class="block">BrowserMatchNoCase mac platform=ibm
BrowserMatchNoCase win platform=windows</pre>
<p><a href="#browsermatch">BrowserMatch</a> and BrowserMatchNoCase are special cases
of <a href="#setenvIf">SetEnvIf</a> and <a href="#setenvifnocase">SetEnvIfNoCase</a>.
The following two lines have the same effect: </p>
<pre class="block">BrowserMatchNoCase Robot is_a_robot
SetEnvIfNoCase User-Agent Robot is_a_robot</pre>
<dl class="block"><dt class="dlterm"><strong>Parameter One</strong>: <em>regex </em></dt>
<dd><ul><li>The <em>regex</em> parameter is a case-insensitive POSIX.2 extended regular
expression. This gives the user the ability to select variants on the User-Agent
field, such as using some wildcarding to group version of a client browser. See <a href="rzaieenvvar.htm">Environment variables on HTTP Server</a> for
more information.</li>
</ul>
</dd>
</dl>
<dl class="block"><dt class="dlterm"><strong>Parameter Two</strong>: <em>envvar[=value] </em></dt>
<dd><ul><li>The <em>envvar[=value]</em> parameter gives the names of variables to set
and, optionally, values to which they should be set. They can take the form
of 'varname', '!varname' or 'varname=value'. The case is preserved when lowercase
characters are specified. Valid values include all EBCDIC characters. The
value must be enclosed in quotation marks if it contains any non-alphanumeric
character or blanks. </li>
</ul>
</dd>
</dl>
</div>
</div>
<div class="hr" id="setenvIf"><a name="setenvIf"><!-- --></a><h2 class="topictitle2">SetEnvIf</h2>
<div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="void" border="0" rules="none"><tbody><tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Module">Module</a></strong>: mod_setenvif </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Syntax">Syntax</a></strong>: SetEnvIf <em>attribute regex envar[=value]
[...] </em></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Default">Default</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Context">Context</a></strong>: <span id="setenvIf__setenvIf_context"><a name="setenvIf__setenvIf_context"><!-- --></a>server config,
virtual host, directory, .htaccess </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Override">Override</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Origin">Origin</a></strong>: <span id="setenvIf__setenvIf_origin"><a name="setenvIf__setenvIf_origin"><!-- --></a>Apache</span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Example">Example</a></strong>: SetEnvIf Request_URI "\.gif$" object_is_image=gif </td>
</tr>
</tbody>
</table>
</div>
<p>SetEnvIf defines environment variables based on attributes of the request.
These attributes can be the values of various HTTP request header fields or
of other aspects of the request. See RFC2068 for more information.</p>
<div class="note"><span class="notetitle">Note:</span> To view the RFC listed above, visit the <a href="http://www.rfc-editor.org/rfcsearch.html" target="_blank">RFC index search engine</a> <img src="www.gif" alt="Link outside Information Center" /> located on the <a href="http://www.rfc-editor.org/" target="_blank">RFC editor</a> <img src="www.gif" alt="Link outside Information Center" /> web site. Search for the RFC number you want to view. The
search engine results display the corresponding RFC title, author, date, and
status.</div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="border" border="1" rules="all"><thead align="left"><tr><th valign="top" width="34.84848484848485%" id="d0e359">Attribute</th>
<th valign="top" width="65.15151515151516%" id="d0e361">Description</th>
</tr>
</thead>
<tbody><tr><td valign="top" width="34.84848484848485%" headers="d0e359 ">Remote_Host </td>
<td valign="top" width="65.15151515151516%" headers="d0e361 ">The hostname (if available) of the client making the
request. </td>
</tr>
<tr><td valign="top" width="34.84848484848485%" headers="d0e359 ">Remote_Addr </td>
<td valign="top" width="65.15151515151516%" headers="d0e361 ">The IP address of the client making the request.</td>
</tr>
<tr><td valign="top" width="34.84848484848485%" headers="d0e359 ">Remote_User </td>
<td valign="top" width="65.15151515151516%" headers="d0e361 ">The authenticated username (if available).</td>
</tr>
<tr><td valign="top" width="34.84848484848485%" headers="d0e359 ">Request_Method </td>
<td valign="top" width="65.15151515151516%" headers="d0e361 ">The name of the method being used (GET, POST).</td>
</tr>
<tr><td valign="top" width="34.84848484848485%" headers="d0e359 ">Request_Protocol</td>
<td valign="top" width="65.15151515151516%" headers="d0e361 ">The name of the method being used (GET, POST).</td>
</tr>
<tr><td valign="top" width="34.84848484848485%" headers="d0e359 ">Request_URI</td>
<td valign="top" width="65.15151515151516%" headers="d0e361 ">The portion of the URL following the scheme and host
portion.</td>
</tr>
</tbody>
</table>
</div>
<p>Some of the more commonly used request header field names include Host,
User-Agent, and Referrer.</p>
<p>If the attribute name does not match any of the special keywords, or any
of the request's header field names, it is tested as the name of an environment
variable in the list of those associated with the request. This allows SetEnvIf
directives to test against the result of prior matches. </p>
<p>Only those environment variables defined by earlier SetEnvIf[NoCase] directives
are available for testing in this manner. Earlier means that they were defined
in a broader context (such as server-wide) or previously in the current directive's
context. For example:</p>
<pre class="block">SetEnvIf Request_URI "\.gif$" object_is_image=gif
SetEnvIf Request_URI "\.jpg$" object_is_image=jpg
SetEnvIf Request_URI "\.xbm$" object_is_image=xbm
:
SetEnvIf Referrer www\.mydomain\.com intra_site_referral
:
SetEnvIf object_is_image xbm XBIT_PROCESSING=1</pre>
<p>The first three will set the environment variable object_is_image if the
request was for an image file, and the fourth sets intra_site_referral if
the referring page was somewhere on the www.mydomain.com Web site. The 5th
statement of the example sets XBIT processing, if the environment variable
object_is_image was set by the directive. </p>
<dl class="block"><dt class="dlterm"><strong>Parameter One</strong>: <em>attribute </em></dt>
<dd><ul><li>The <em>attribute</em> parameter is the attribute of the request, such as
an HTTP header value. The attribute can also be an environment variable that
was set by an earlier SETENVIF directive. </li>
</ul>
</dd>
</dl>
<dl class="block"><dt class="dlterm"><strong>Parameter Two</strong>: <em>regex </em></dt>
<dd><ul><li>The <em>regex</em> parameter is a case-sensitive POSIX.2 extended regular
expression. This gives the user the ability to select variants on the Attribute
field, such as using some wildcarding to group related values, and use those
to set the environment variables. See <a href="rzaieenvvar.htm">Environment variables on HTTP Server</a> for
more information.</li>
</ul>
</dd>
</dl>
<dl class="block"><dt class="dlterm"><strong>Parameter Three</strong>: <em>envvar[=value] </em></dt>
<dd><ul><li>The <em>envvar[=value]</em> gives the names of variables to set and, optionally,
values to which they should be set. They take the form of 'varname', '!varname'
or 'varname=value'. The case is preserved when lowercase characters are specified.
Valid values include all EBCDIC characters. The value must be enclosed in
quotation marks if it contains any non-alphanumeric character or blanks. </li>
</ul>
</dd>
</dl>
</div>
</div>
<div class="hr" id="setenvifnocase"><a name="setenvifnocase"><!-- --></a><h2 class="topictitle2">SetEnvIfNoCase</h2>
<div>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" frame="void" border="0" rules="none"><tbody><tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Module">Module</a></strong>: mod_setenvif </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Syntax">Syntax</a></strong>: SetEnvIfNoCase <em>attribute regex envar[=value]
[...] </em></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Default">Default</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Context">Context</a></strong>: <span id="setenvifnocase__setenvifnocase_context"><a name="setenvifnocase__setenvifnocase_context"><!-- --></a>server
config, virtual host, directory .htaccess </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Override">Override</a></strong>: none </td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Origin">Origin</a></strong>: <span id="setenvifnocase__setenvifnocase_origin"><a name="setenvifnocase__setenvifnocase_origin"><!-- --></a>Apache </span></td>
</tr>
<tr><td colspan="2" valign="top"><strong><a href="rzaiedirective-dict.htm#rzaiedirective-dict__Example">Example</a></strong>: SetEnvIfNoCase Host IBM\.Org site=ibm </td>
</tr>
</tbody>
</table>
</div>
<p>SetEnvIfNoCase is semantically identical to <a href="#setenvIf">SetEnvIf</a>,
and differs only in that the regular expression matching is performed in a
case-insensitive manner. For example: </p>
<pre class="block">SetEnvIfNoCase Host QIBM\.Org site=ibm</pre>
<p>This will cause the site variable to be set to 'ibm' if the HTTP request
header field Host: was included and contained QIBM.Org, qibm.org, or any other
combination. </p>
<dl class="block"><dt class="dlterm"><strong>Parameter One</strong>: <em>attribute </em></dt>
<dd><ul><li>The <em>attribute</em> parameter is the attribute of the request, such as
an HTTP Header value. The attribute can also be an environment variable that
was set by an earlier setenvif directive. </li>
</ul>
</dd>
</dl>
<dl class="block"><dt class="dlterm"><strong>Parameter Two</strong>: <em>regex </em></dt>
<dd><ul><li>The regex parameter is a case-sensitive POSIX.2 extended regular expression.
This gives the user the ability to select variants on the Attribute field,
such as using some wildcarding to group related values, and use those to set
the environment variables. See <a href="rzaieenvvar.htm">Environment variables on HTTP Server</a> for
more information.</li>
</ul>
</dd>
</dl>
<dl class="block"><dt class="dlterm"><strong>Parameter Three</strong>: <em>envvar[=value]</em></dt>
<dd><ul><li>The <em>envvar[=value]</em> parameter gives the names of variables to set
and, optionally, values to which they should be set. They take the form of
'varname', '!varname' or 'varname=value'. The case is preserved when lowercase
characters are specified. Valid values include all EBCDIC characters. The
value must be enclosed in quotation marks if it contains any non-alphanumeric
character or blanks. </li>
</ul>
</dd>
</dl>
</div>
</div>
</body>
</html>