1

在 Apache 中,我们有时会使用 410 GONE http 状态代码来指示资源已经转移给爬虫等,以及供人类访问者使用的 html 页面。

我们要么使用过类似的东西:

ErrorDocument 410 ourmovedpage.html
...
Redirect gone /GONECONTENT

服务器提供 410 状态代码以及向浏览器访问者显示“ourmovedpage”地址。

使用 Nginx,我已经尝试过

location = /gonecontent-address {
  error_page 404 =410 $scheme://ourdomain/ourmovedpage.html;
}

但在测试中,Chrome 似乎显示的是 302 重定向状态代码,而不是我所追求的 410。

有没有人想出类似的东西让 Nginx 发送一个 410,但也为人类访问者返回一个漂亮的页面?

4

1 回答 1

0

通过指定完整的 URLnginx强制执行重定向。您应该指定相对于当前服务器的人类可读页面。

location = /gonecontent-address {
    error_page 404 =410 /ourmovedpage.html;
}
于 2017-03-10T08:38:21.633 回答