fix bug causing return to current url in redirect loop