How to clear fragment identifier on 302 redirect?

192 views Asked by At

It seems that after a 302 direct, the browser preserves the fragment identifier:

/foo#/bar/baz

returns 302 to /login, but browser shows:

/login#/bar/baz

How do I get the browser to redirect and clear the fragment so it just shows:

/login
1

There are 1 answers

0
aaa90210 On

It seems that if the server adds '#' to the end of the redirect URL it will override any existing fragment. Of course, the redirect URL must tolerate an empty fragment, but if so, the redirect header can simply be:

Location /login#

Works for me.