大网数据广告活动
服务器运维问答

IF Condition in Apache 2.4 is always executed

· 52CE 我爱测

I am trying to load a module based on a condition. {PHPMODULENAME} is replaced in the config by the AMP Server I am using - so please don't get confused. <If "'{PHPMODULENAME}' == 'php8_module'"> LoadModule module1 "..." </If> <E…

问题原文

原帖链接 · ESP32 · CC BY-SA 4.0

I am trying to load a module based on a condition. {PHPMODULENAME} is replaced in the config by the AMP Server I am using - so please don't get confused.

<If "'{PHPMODULENAME}' == 'php8_module'">
    LoadModule module1 "..."
</If>
<Else>
    LoadModule module2 "..."
</Else>

If the condition is true it should load module1 - because only then the module1 is available and module2 isn't. And vice versa.

However when I try to start Apache, it throws an error, because either module1 or module2 is missing. I know that - that's why I add the IF condition.

已采纳解答

原帖链接 · HBruijn · CC BY-SA 4.0

Apache httpd provides a specific conditional to test for the presence of a module :

The < IfModule > directive:

Description: Encloses directives that are processed conditional on the presence or absence of a specific module
Syntax: <IfModule [!]module-file|module-identifier> ... </IfModule>

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-05-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。