当我们通过
add_header 添加 HTTP 响应头信息后,200 正常页面能够看到 HEADER 信息,但是 404 页面没有,为了解决这个问题,可以在 add_header 后面加上 always 让他始终添加头信息。添加前:
server {
listen 80 default;
add_header X-Robots-Tag noindex;
...
}$ curl -I "http://domain.tld/does/not/exist"
HTTP/1.1 404 Not Found
...添加后:
server {
listen 80 default;
...
add_header X-Robots-Tag noindex always;
...
}