Apache HTTP Server 版本 2.4

| 描述 | 版本相关的配置 |
|---|---|
| 状态 | 扩展 |
| 模块标识符 | version_module |
| 源文件 | mod_version.c |
此模块旨在用于测试套件和大型网络,这些网络必须处理不同的 httpd 版本和不同的配置。它提供了一个新的容器 - <IfVersion>,它允许灵活的版本检查,包括数字比较和正则表达式。
<IfVersion 2.4.2>
# current httpd version is exactly 2.4.2
</IfVersion>
<IfVersion >= 2.5>
# use really new features :-)
</IfVersion>
有关更多可能性,请参见下文。
| 描述 | 包含版本相关的配置 |
|---|---|
| 语法 | <IfVersion [[!]operator] version> ... </IfVersion> |
| 上下文 | 服务器配置、虚拟主机、目录、.htaccess |
| 覆盖 | 全部 |
| 状态 | 扩展 |
| 模块 | mod_version |
The <IfVersion> section encloses configuration directives which are executed only if the httpd version matches the desired criteria. For normal (numeric) comparisons the version argument has the format major[.minor[.patch]], e.g. 2.1.0 or 2.2. minor and patch are optional. If these numbers are omitted, they are assumed to be zero. The following numerical operators are possible
| 运算符 | 描述 |
|---|---|
= 或 == |
httpd 版本相等 |
> |
httpd 版本大于 |
>= |
httpd 版本大于或等于 |
< |
httpd 版本小于 |
<= |
httpd 版本小于或等于 |
<IfVersion >= 2.3>
# this happens only in versions greater or
# equal 2.3.0.
</IfVersion>
除了数字比较之外,还可以将 正则表达式 与 httpd 版本进行匹配。有两种方法可以编写它
| 运算符 | 描述 |
|---|---|
= 或 == |
version 的形式为 /regex/ |
~ |
version 的形式为 regex |
<IfVersion = /^2.4.[01234]$/>
# e.g. workaround for buggy versions
</IfVersion>
为了反转含义,所有运算符都可以用感叹号 (!) 开头
<IfVersion !~ ^2.4.[01234]$>
# not for those versions
</IfVersion>
如果省略 operator,则假定为 =。