Forum Discussion

Sorin_Rusnac_86's avatar
Sorin_Rusnac_86
Icon for Nimbostratus rankNimbostratus
Mar 27, 2008

http redirect ?

Hi -

 

 

I am trying to do a redirect as such:

 

 

when HTTP_REQUEST {

 

HTTP::redirect "http://[HTTP::host]/mysite/test1"

 

}

 

 

I dont get any errors but when I apply the irule it does not seem to work. If I do this:

 

 

when HTTP_REQUEST {

 

HTTP::redirect "http://[HTTP::host][HTTP::uri]"

 

}

 

 

it does work however I want the F5 to always send it to HTTP::host /mysite/test1 so the /mysite/test1 will never change.

 

 

 

Thanks

1 Reply

  • Hi,

    when HTTP_REQUEST {

    HTTP::redirect "http://[HTTP::host]/mysite/test1"

    }

    Here you create an infinite loop since it will be triggered on every HTTP request.

    you should try something like this:

    
    when HTTP_REQUEST {
      if { not ([HTTP::uri] contains "mysite") } {
        HTTP::redirect "http://[HTTP::host]/mysite/test1"
      }
    }

    This way if the uri contains mysite, it means the client has already been redirected and shouldn't be redirected anymore

    HTH