Forum Discussion

paul_dcc's avatar
paul_dcc
Icon for Nimbostratus rankNimbostratus
Jul 16, 2010

HTTP Redirect

Hi All,

 

 

I created a simple Irule to do a redirect, but when I test this it takes me to the wrong page beacause it add a / to the end of the url string which I do not require,

 

 

Could some one please help with my problem

 

 

Thanks

 

 

Paul

 

 

when HTTP_REQUEST {

 

 

Check host header value

 

if {[string tolower [HTTP::host]] eq "des.dorsetcc.local"}{

 

 

Redirect client to the full host name

 

HTTP::redirect "]"

 

}

 

}
  • What exactly are you trying to redirect users to? Since you're putting [HTTP::uri] at the end of the iRule, it's going to insert the "/" because that's the URI they're specifying.

     

     

    If you go to, www.google.com for instance, your browser will likely look for the uri "/" at host "www.google.com".

     

     

    In your case, "/" is the URI, hence why it's being appended.
  • Cheers Chris,

     

     

    I'm a network engineer and was not sure what that was there for any way, but it works fine now.

     

     

    Thanks

     

     

    PAul.
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Paul,

     

     

    If the clients could be sending a request to the original hostname with a full query string, you should consider URL encoding the original URI before appending it to the new URI using the URI::encode command. See this post for more info:

     

     

    URI::encode question

     

    http://devcentral.f5.com/Forums/tabid/1082223/asg/50/showtab/groupforums/aff/5/aft/61577/afv/topic/Default.aspx61591

     

     

    URI::encode wiki page

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/uri__encode

     

     

    Aaron