Trying to get rid of redirect loop