Forum Discussion

Tom_Bell_15050's avatar
Tom_Bell_15050
Icon for Nimbostratus rankNimbostratus
Jun 10, 2010

Irule Redirect to one pool if 404 received from the first.

Howdy Guys,

 

My business has presented me with the following issue. They want traffic to a particular URL served from a static pool and if the file isn't present, we detect the 404 and redirect the request to another pool which serve's the file.

 

 

I've written the following rule and am yet to test it .. however I'm rather sure it's not going to perform as a I wish. If anyone has a suggestion I'd love to here it.

 

 

when HTTP_REQUEST {

 

set uri [HTTP::uri]

 

if {$url starts_with "/static/"} {

 

pool stage-static

 

}

 

}

 

 

when HTTP_RESPONSE {

 

set status [HTTP::status]

 

if {$status eq "404" and $url starts_with "/static/"} {

 

clone pool stage-web

 

}

 

}

 

 

Thanks

 

 

Tom

 

2 Replies

  • How about something like this:

    
     when HTTP_REQUEST {
    if { [HTTP::uri] starts_with "/static" } {
    set uri [HTTP::uri]
    pool stage-static
    }
    }
    when HTTP_RESPONSE {
    if { [HTTP::status] == 404 and $uri contains "/static" } {
    HTTP::redirect "/"
    }
    }
    
  • Here's a related example for retrying the HTTP request after a specific status code is seen:

     

     

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

     

     

    Aaron