Fixed handling redirect for ajx and non-ajax together