当前位置: 移动技术网 > 网络运营>服务器>nginx > nginx add_header指令使用方法

nginx add_header指令使用方法

2019年04月22日  | 移动技术网网络运营  | 我要评论

response header一般都是以key:value的形式,例如:“content-encoding:gzip、cache-control:no-store”,设置的命令为:

复制代码 代码如下:

add_header cache-control no-store
add_header content-encoding gzip

但是有一个十分常用的response header比较特性,就是content-type,可以在它设置了类型的同时还会指定charset,例如:“text/html; charset=utf-8”,由于其存在分号,而分号在配置文件中作为结束符,所以在配置的时候需要用引号把其引起来,配置如下:

复制代码 代码如下:

add_header  content-type 'text/html; charset=utf-8';

另外由于没有单独设置charset的key,所以要设置响应的charset就需要使用content-type来指定charset。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网