aaa90210
aaa90210

Reputation: 12093

How to clear fragment identifier on 302 redirect?

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

Upvotes: 1

Views: 213

Answers (1)

aaa90210
aaa90210

Reputation: 12093

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.

Upvotes: 1

Related Questions