added redirect rules
added redirect logic and fixed challenge limit
fixed secure server port handling