HX-Redirect 响应标头

此响应标头可用于触发客户端重定向到新的 url,该 url 将完全重新加载整个页面。它使用浏览器重定向到新位置,这在重定向到可能包含不同 HTML head 内容或脚本的非 htmx 端点时非常有用。如果你想要更好地控制重定向或想要使用 ajax 请求而不是完全重新加载浏览器,请参阅 HX-Location

¥This response header can be used to trigger a client side redirection to a new url that will do a full reload of the whole page. It uses the browser to redirect to the new location which can be useful when redirecting to non htmx endpoints that may contain different HTML head content or scripts. See HX-Location if you want more control over the redirect or want to use ajax requests instead of full browser reloads.

示例响应如下:

¥A sample response would be:

HX-Redirect: /test

哪个会推动客户端进行测试,就好像用户手动输入了此 url 或单击了非增强链接 <a href="/test"> 一样

¥Which would push the client to test as if the user had entered this url manually or clicked on a non-boosted link <a href="/test">

注释

¥Notes

3xx 响应代码不会处理响应标头。参见 响应标头

¥Response headers are not processed on 3xx response codes. see Response Headers