替换响应内容
http_sub_module
对http响应内容的替换。
# 针对指定内容进行替换,将string替换为replacement
Syntax: sub_filter string replacement;
Default:
Context: http, server, location
# 指定匹配方式,匹配以此还是每个都匹配,默认匹配一次
Syntax: sub_filter_once on | off;
Default: sub_filter_once on;
Context: http, server, location
# nginx服务端与客户端,进行每次请求时校验服务端的内容是否发生变化
# last_modified 记录了时间,判断服务端数据是否更新,从而保证数据最新,常用于缓存场景
Syntax: sub_filter_last_modified on | off;
Default: sub_filter_last_modified off;
Context: http, server, location
实例:
location / {
root html;
# 所有都替换
sub_filter_once off;
# 将所有hello 替换为 HELLO
sub_filter 'hello' 'HELLO';
}
最后更新于
这有帮助吗?