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

apache mod_substitute works in curl but not on browser

· 52CE 我爱测

I have a mod_substitute as below, which works perfectly fine in curl but not on browser. Also, it works on all pages except one page. I would like to know what would cause mod_substitute not work on browser? how to debug and fix …

问题原文

原帖链接 · Hema · CC BY-SA 3.0

I have a mod_substitute as below, which works perfectly fine in curl but not on browser. Also, it works on all pages except one page.

I would like to know what would cause mod_substitute not work on browser? how to debug and fix this issue?

社区高分解答

原帖链接 · Petter H · CC BY-SA 3.0

To troubleshoot such issues, it is a good idea to compare the headers in the browser with the ones in curl (-i, --include flag will show headers, and -H flag can add them), and from the browser add one at a time to curl command until the problem reproduces.

I read in the comments section of mod_substitute docs page that describes symptoms like the ones you described, with mod_substitute sometimes not working as expected:

It turned out it was the order of our filter chain. DEFLATE was running before SUBSTITUTE. For small files, DEFLATE was not doing anything, so it worked. On some internal proxy stuff that did not send an Accept-Encoding header it was working. But, other times it did not. In the end, this worked best:

AddOutputFilterByType INFLATE;SUBSTITUTE;DEFLATE text/html text/plain text/xml

Another option is to unset Accept-Encoding header for the target resource where mod_substitute is supposed to do it's substitutions.

RequestHeader unset Accept-Encoding

It's (arguably) better to use the other trick instead, so that you can reap the benefits both of mod_deflate and mod_substitute though.

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

资料来源与适用范围

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

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

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