Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 57
    Note: Similar behaviour to HTTP redirect for replace() means it won't create an entry in your browser's history. Commented Oct 5, 2020 at 22:51
  • 9
    If you display a page only to make a redirect, location.replace() will probably be more appropriate (exclude the page with a redirect from history). But why don't you do the redirect on the server side in the first place? Commented Mar 12, 2021 at 12:35
  • 3
    If anyone still has a problem that all the great answers you've applied but page redirect is not working then please visit: stackoverflow.com/questions/15759020/… it works for my case. Commented Aug 18, 2021 at 5:39
  • @x-yuri my use-case is that URI fragments (after the # symbol) are not preserved via a server-side redirect because they're not sent to the server. Commented Nov 15, 2021 at 23:48
  • 2
    @x-yuri in my case, I moved the service that served those URLs with the URI fragments, and wanted old hyperlinks that people may have bookmarked to continue to work by redirecting them to the new site and preserving the fragment. You're right that the framework uses fragments instead of query parameters for some reason. Commented Nov 17, 2021 at 5:51