文章标签 ‘nginx-charset’

nginx add header 指令

2013年9月22日 没有评论

nginx配置文件通过使用add_header指令来设置response header,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。

分类: nginx 标签: ,

无觅相关文章插件,快速提升流量