我已经升级到Apache 2.4,我需要改变所有
Order allow,deny Allow from all
至
Require all granted
但是,这导致这些虚拟主机文件在Apache 2.2上停止工作。
有没有办法在configuration中编写一些IF
来获得相同的虚拟主机文件,以便为这两个版本工作?
你可以使用mod_version
( link )
<IfVersion >= 2.4> Require all granted </IfVersion> <IfVersion < 2.4> Order allow,deny Allow from all </IfVersion>
在等待答案时,我似乎find了解决办法:
<IfModule mod_authz_core.c> # Apache 2.4 Require all granted </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order deny,allow Allow from all </IfModule>
显然你可以检查是否存在特定的模块,并使Apache2做相应的东西。