Currently, AMP pages remain in the browser history, so if we imagine the following request flow:
- Google Search
- El Reg AMP page
- El Reg HTML page
When the user is on El Reg HTML Page they may press back in order to go back to the search results.
What'll actually happen though is their browser will go back to the AMP page, which will trigger the redirect and then put them back onto the HTML page.
Rather than setting window.location.href when triggering a redirect, we should use window.location.replace() so that the current (i.e. AMP) page isn't written into the browser's history.
That way, a back on the El Reg HTML page would take you back to the Google search results