我可以让 Apache 更改响应状态代码吗?
我有很多服务都使用相同的代码块,并且全部错误地返回 406(不可接受),而真正想要的是 410(消失)。这种差异不仅仅是正确性之一,而且对上游还有其他影响,因为 410 可以缓存,而 406 则不能。
从长远来看,所有底层代码都必须进行更改和重新测试,这需要时间和金钱。
同时,如果我可以在所有 406 响应通过 Apache 2.2 前端时将其更改为 410,那就太酷了。
这里有人能帮我快速获胜吗?
提前致谢。
I have a load of services all using the same block of code and all incorrectly returning a 406 (Not acceptable) when what was really wanted was a 410 (Gone). The difference is not simply one of correctness, but has other implications upstream as 410s can be cached and 406s can't.
In the long run all the underlying code is going to have to be altered and retested and it'll take time and money.
In the meanwhile it would be cool if I could simply alter all 406 responses to become a 410 as they pass through the Apache 2.2 front end.
Does anyone have a quick win for me here?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这感觉像是一个可怕的黑客,但你可以配置一个 错误文档对于本身发送 410 状态代码的所有 406 响应:
This feels like a horrible hack but you could configure an error document for all 406 responses that itself sends a 410 status code: