redirect is keeping hash

前端 未结 2 555
再見小時候
再見小時候 2021-01-18 11:14

For some reason when I redirect with header(\"Location\") the new page keeps the hash.

So if you\'re on example.com/index.html#signup

2条回答
  •  别那么骄傲
    2021-01-18 11:32

    The simple answer to "how do I stop it" is to specify an empty hash in the Location header:

    header('Location: /account.html#');
    

    However, this behavior isn't guaranteed across the board. It seems to work in WebKit and IE9 in my quick test. Nevertheless, you've stumbled on a black hole in the HTTP specification.

提交回复
热议问题