added redirect support adn removed infinite redirect situation