Fixing redirect loop caused by application routing logic