htmx/www/content/headers/hx-replace-url.md
MichaelWest22 6ce6a1a77b
Documentation 3xx redirects can't send headers (#2904)
* 3xx redirects can't send headers

* fix response-headers links
2024-09-15 09:29:39 +02:00

20 lines
982 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

+++
title = "HX-Replace-Url Response Header"
+++
The `HX-Replace-Url` header allows you to replace the current URL in the browser [location history](https://developer.mozilla.org/en-US/docs/Web/API/History_API).
This does not create a new history entry; in effect, it removes the previous current URL from the browser’s history.
This is similar to the [`hx-replace-url` attribute](@/attributes/hx-replace-url.md).
If present, this header overrides any behavior defined with attributes.
The possible values for this header are:
1. A URL to replace the current URL in the location bar.
This may be relative or absolute, as per [`history.replaceState()`](https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState), but must have the same origin as the current URL.
2. `false`, which prevents the browsers current URL from being updated.
## Notes
Response headers are not processed on 3xx response codes. see [Response Headers](@/docs.md#response-headers)