【发布时间】:2021-07-22 22:54:50
【问题描述】:
在 Apache 服务器中,如果匹配特定 URL,我需要禁用 keepalive。
为此,我使用 mod_rewrite 对其进行设置,然后让脚本运行。
RewriteCond %{REQUEST_URI} ^/specific_url
RewriteRule ^ - [E=nokeepalive]
.......
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
现在我的问题是 nokeepalive 如果匹配,最终会被前缀/重命名为 REDIRECT_
从这个问题:When setting environment variables in Apache RewriteRule directives, what causes the variable name to be prefixed with "REDIRECT_"?
我认为这是由于RewriteRule
但它没有前缀 如果我删除 RewriteCond (这将禁用 keepAlive globaly 与任何 URL)
有没有办法用 RewriteCond 防止这个前缀?
我不能使用SetEnvIf,因为我使用mod_rewrite,所以我必须使用RewriteRule。
SetEnv/SetEnviF 也不起作用,因为它们无法读取未使用 SetEnv/SetEnvif 分配的变量。 我尝试使用 SetEnvIf 仅在 REDIRECT_nokeepalive 存在时进行定义(因为无论值如何,都必须定义 nokeepalive) - 但无济于事。
【问题讨论】:
标签: apache mod-rewrite