如何使用Apache 2.4上的标记<If ...>测试文件是否存在?

Jer*_*mie 12 apache if-statement httpd.conf

我想在Apache 2.4的httpd.conf中测试一个文件的存在.

我使用这样的标签:

<If "%{DocumentRoot}/maintenance.enable -f"> ...code to execute ... </If>

但我的代码不好,apache的服务不想启动.我在很多网站上阅读了很多教程或文档,但从未找到答案:(

请帮我 ...

jul*_*ulp 17

阅读Apache错误日志,它是: <If "-f %{DOCUMENT_ROOT} . '/maintenance.enable'">


Tai*_*aul 5

对于 Apache 2.4.34 及更高版本,可以使用的替代指令是<IfFile>

在这种情况下,语法是:

<IfFile %{DOCUMENT_ROOT} . '/maintenance.enable'>
... code to execute ...
</IfFile>
Run Code Online (Sandbox Code Playgroud)