Forum Discussion

Glenn_Ruffus_10's avatar
Glenn_Ruffus_10
Icon for Nimbostratus rankNimbostratus
Sep 26, 2006

iRule for specific HTTP redirect

I would appreciate help in writing a simple iRule that will look for traffic coming in on some virtual servers that contains a specific URL/URI and will then redirect the browser to go to a slightly different but specific URL/URI. For instance:

 

 

if the HTTP request is for "fredflintstone.com/a/b/c/d/default.asp"

 

 

then redirect the browser to use "http://www.fredflintstone.com/a/b/c/d/default.asp"

 

 

I have something written and it's probably close but I would really appreciate an expert's suggestion to compare it with.

 

 

Thanks.

 

 

Glenn

 

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi Glenn,

    There are a few different ways to do this. If you only have a small number of host/URI combinations you want to look for, you could use if/else statements. If you have more comparisons to make, you could use a switch or a class comparison.

    Here is an if/else example to get started:

    
    when HTTP_REQUEST { 
       if { [string tolower [HTTP::host]] equals "fredflintstone.com"  and [HTTP::uri] equals "/a/b/c/d/default.asp" }
          HTTP::redirect "http://www.fredflintstone.com/a/b/c/d/default.asp"
       }
       else {
          pool http_pool
       }
    }

    If you want further examples, post what you've got so far and what's not working.

    Aaron