Forum Discussion

SteveVernau_132's avatar
SteveVernau_132
Icon for Nimbostratus rankNimbostratus
May 08, 2014

infinite redirect irule using http::redirect

The problem with this irule is the bit that redirects careers.mysite.com.au to www.mysite.com.au/about-us/Working-With-Us (ignore the rest, it all works fine) You end up having the browser go to http://careers.australianunity.com.au/www.australianunity.com.au/about-us/www.australianunity.com.au/about-us/www.australianunity.com.au/about-us/..... and on and on, ad infinitum. Its interesting that the /working-with-us after the /about-us/ us not part of the infinite redirect loops

 

Now careers.mysite.com.au and www.mysite.com.au both point to the same ip address - which is of the virtual server that has this irule attached. I suspect that because it keeps getting reprocessed that is the issue but I would have thought that the first time it hits the VS it gets changed from careers.australianunity.com.au then browser is told to redirect to www.australianunity.com.au/about-us/ which should no longer match the if condition and not cause this loop but obviously I am wrong somewhere!!

 

when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] set host [string tolower [HTTP::host]] if { $host contains "careers.mysite.com.au" } { HTTP::redirect "www.mysite.com.au/about-us/Working-With-Us" } elseif { $uri contains "health-insurance/online-services" } { pool www.mysite.com.au-tst-oms-http80-pol } elseif { $uri contains "providerportal" } { pool www.mysite.com.au-tst-pportal-http80-pol } else { pool www.mysite.com.au-tst-sitecore-http80-pol } }

 

  • First guess is that the browser thinks your redirect is a relative URI. Try this:

    when HTTP_REQUEST { 
        set uri [string tolower [HTTP::uri]] 
        set host [string tolower [HTTP::host]] 
    
        if { $host equals "careers.mysite.com.au" } { 
            HTTP::redirect "http://www.mysite.com.au/about-us/Working-With-Us" 
        } elseif { $uri contains "health-insurance/online-services" } { 
            pool www.mysite.com.au-tst-oms-http80-pol 
        } elseif { $uri contains "providerportal" } { 
            pool www.mysite.com.au-tst-pportal-http80-pol 
        } else { 
            pool www.mysite.com.au-tst-sitecore-http80-pol 
        } 
    }
    
  • The main point was adding the protocol definition to the front of the address.

    http://www.mysite.com.au