Forum Discussion

Phil_Carroll_13's avatar
Phil_Carroll_13
Icon for Nimbostratus rankNimbostratus
Aug 14, 2013

Conditional redirect based on passed parameters...

Hello All,

 

I need help with creating a rule that would do the following...

 

If the http request is www.domain.com or domain.com then it needs redirected to www.redirect.domain\page

 

If the http request is www.domain.com\token&parameters then I need to let that pass un-altered.

 

Is such a rule possible?

 

3 Replies

  • Andres_4712's avatar
    Andres_4712
    Historic F5 Account

    Taking your goal description literally (redirect if URI does not containg strings), irule would be very simple:

    when HTTP_REQUEST {
    if { [HTTP::uri] eq "/"}{
    HTTP::redirect http://www.redirect.domain\page
    }
    }
    

    I would point that the real URL whould be:

    http://www.redirect.domain/page

  • That doesn't account for the specific domain, though, and I think the intent is that /page is whatever was sent to the original request as a uri. If that's the case, Phil, something like this should work:

    when HTTP_REQUEST {
      if { [domain [HTTP::host] 2] eq "domain.com" } {
        HTTP::redirect "http://www.redirect-domain.com[HTTP::uri]"
      }
    } 
    
  • Andres_4712's avatar
    Andres_4712
    Historic F5 Account

    That could be true. Good point Jason.

     

    Within the description the only difference in the requests was the URI:

     

    Case a:

     

    www.domain.com

     

    then : redirect.

     

    Case b:

     

    www.domain.com\token&parameters

     

    then "Forward".

     

    So I based the decision for the redirect in URI. Phill has the last word :).