Stop endless redirect loop

fix #3931
Allow 5 redirects