1<?xml version="1.0" encoding="ISO-8859-1"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!-- 4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 5 This file is generated from xml source: DO NOT EDIT 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 7 --> 8<title>mod_version - Apache HTTP Server</title> 9<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> 10<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> 11<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" /> 12<script src="/style/scripts/prettify.js" type="text/javascript"> 13</script> 14 15<link href="/images/favicon.ico" rel="shortcut icon" /></head> 16<body> 17<div id="page-header"> 18<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p> 19<p class="apache">Apache HTTP Server Version 2.2</p> 20<img alt="" src="/images/feather.gif" /></div> 21<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div> 22<div id="path"> 23<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Modules</a></div> 24<div id="page-content"> 25<div id="preamble"><h1>Apache Module mod_version</h1> 26<div class="toplang"> 27<p><span>Available Languages: </span><a href="/en/mod/mod_version.html" title="English"> en </a> | 28<a href="/ja/mod/mod_version.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 29<a href="/ko/mod/mod_version.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p> 30</div> 31<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Version dependent configuration</td></tr> 32<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr> 33<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>version_module</td></tr> 34<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_version.c</td></tr> 35<tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.56 and later</td></tr></table> 36<h3>Summary</h3> 37 38 <p>This module is designed for the use in test suites and large 39 networks which have to deal with different httpd versions and 40 different configurations. It provides a new container -- <code class="directive"><a href="#ifversion"><IfVersion></a></code>, which 41 allows a flexible version checking including numeric comparisons and 42 regular expressions.</p> 43 44 <div class="example"><h3>Examples</h3><p><code> 45 <IfVersion 2.1.0><br /> 46 <span class="indent"> 47 # current httpd version is exactly 2.1.0<br /> 48 </span> 49 </IfVersion><br /> 50 <br /> 51 <IfVersion >= 2.2><br /> 52 <span class="indent"> 53 # use really new features :-)<br /> 54 </span> 55 </IfVersion> 56 </code></p></div> 57 58 <p>See below for further possibilities.</p> 59</div> 60<div id="quickview"><h3 class="directives">Directives</h3> 61<ul id="toc"> 62<li><img alt="" src="/images/down.gif" /> <a href="#ifversion"><IfVersion></a></li> 63</ul> 64<ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> 65 66<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 67<div class="directive-section"><h2><a name="IfVersion" id="IfVersion"><IfVersion></a> <a name="ifversion" id="ifversion">Directive</a></h2> 68<table class="directive"> 69<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>contains version dependent configuration</td></tr> 70<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><IfVersion [[!]<var>operator</var>] <var>version</var>> ... 71</IfVersion></code></td></tr> 72<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr> 73<tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr> 74<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 75<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_version</td></tr> 76</table> 77 <p>The <code class="directive"><IfVersion></code> section encloses 78 configuration directives which are executed only if the 79 <code class="program"><a href="/programs/httpd.html">httpd</a></code> version 80 matches the desired criteria. For normal (numeric) comparisons the 81 <var>version</var> argument has the format 82 <code><var>major</var>[.<var>minor</var>[.<var>patch</var>]]</code>, e.g. 83 <code>2.1.0</code> or <code>2.2</code>. <var>minor</var> and 84 <var>patch</var> are optional. If these numbers are omitted, they are 85 assumed to be zero. The following numerical <var>operator</var>s are 86 possible:</p> 87 88 <table class="bordered"><tr class="header"><th><var>operator</var></th><th>description</th></tr> 89<tr><td><code>=</code> or <code>==</code></td> 90 <td>httpd version is equal</td></tr> 91<tr class="odd"><td><code>></code></td> 92 <td>httpd version is greater than</td></tr> 93<tr><td><code>>=</code></td> 94 <td>httpd version is greater or equal</td></tr> 95<tr class="odd"><td><code><</code></td> 96 <td>httpd version is less than</td></tr> 97<tr><td><code><=</code></td> 98 <td>httpd version is less or equal</td></tr> 99</table> 100 101 <div class="example"><h3>Example</h3><p><code> 102 <IfVersion >= 2.1><br /> 103 <span class="indent"> 104 # this happens only in versions greater or<br /> 105 # equal 2.1.0.<br /> 106 </span> 107 </IfVersion> 108 </code></p></div> 109 110 <p>Besides the numerical comparison it is possible to match a 111 <a class="glossarylink" href="/glossary.html#regex" title="see glossary">regular expression</a> 112 against the httpd version. There are two ways to write it:</p> 113 114 <table class="bordered"><tr class="header"><th><var>operator</var></th><th>description</th></tr> 115<tr><td><code>=</code> or <code>==</code></td> 116 <td><var>version</var> has the form 117 <code>/<var>regex</var>/</code></td></tr> 118<tr class="odd"><td><code>~</code></td> 119 <td><var>version</var> has the form 120 <code><var>regex</var></code></td></tr> 121</table> 122 123 <div class="example"><h3>Example</h3><p><code> 124 <IfVersion = /^2.1.[01234]$/><br /> 125 <span class="indent"> 126 # e.g. workaround for buggy versions 127 </span> 128 </IfVersion> 129 </code></p></div> 130 131 <p>In order to reverse the meaning, all operators can be preceded by an 132 exclamation mark (<code>!</code>):</p> 133 134 <div class="example"><p><code> 135 <IfVersion !~ ^2.1.[01234]$><br /> 136 <span class="indent"> 137 # not for those versions<br /> 138 </span> 139 </IfVersion> 140 </code></p></div> 141 142 <p>If the <var>operator</var> is omitted, it is assumed to be 143 <code>=</code>.</p> 144 145</div> 146</div> 147<div class="bottomlang"> 148<p><span>Available Languages: </span><a href="/en/mod/mod_version.html" title="English"> en </a> | 149<a href="/ja/mod/mod_version.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 150<a href="/ko/mod/mod_version.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p> 151</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div> 152<script type="text/javascript"><!--//--><![CDATA[//><!-- 153var comments_shortname = 'httpd'; 154var comments_identifier = 'http://httpd.apache.org/docs/2.2/mod/mod_version.html'; 155(function(w, d) { 156 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 157 d.write('<div id="comments_thread"><\/div>'); 158 var s = d.createElement('script'); 159 s.type = 'text/javascript'; 160 s.async = true; 161 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 162 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 163 } 164 else { 165 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 166 } 167})(window, document); 168//--><!]]></script></div><div id="footer"> 169<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> 170<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- 171if (typeof(prettyPrint) !== 'undefined') { 172 prettyPrint(); 173} 174//--><!]]></script> 175</body></html>