Here's one that combines uri modification with using cookies to keep the users on the same backend server.

The current issue is this: Is there a way to use an iRule *once* to re-direct a query, and once it has been used, to have the F5 re-direct all further requests there without having to read the iRule again.

We have two back end web servers that will be accessed using the following URL's

webpr.tsl.telus.com/ASF
webpr.tsl.telus.com/CM

The reason I have to chop off either 'ASF' or 'CM' is that the web servers do not know about ASF or CM. There are no subfolders on these web servers called ASF or CM, so a request like webpr.tsl.telus.com/ASF/index.html really gets translated to http://server01/index.html.

That part works fine. The problem is that when you ask for webpr.tsl.telus.com/ASF/index.html, the html code returned by the back end server contains some of the following:

Notice that the source is not /ASF/img/front/pic_home_title.gif, it is /img/front/pic_home_title.gif. When this request goes back through the iRule, it gets dropped. But there is no garantee that the images I want will be on that specific pool.

The uri manipulation has already been illustrated in: iRule: modifying the uri without a redirect. All that needs to be done now is to whip up some cookies and toss them into the request processing. unRuleY again shows his stuff with this example.
when CLIENT_ACCEPTED {
   set app_cookie ""
   set cookie_added 0
}
when HTTP_REQUEST {
   set uri [HTTP::uri]
   if { $uri starts_with "/ASF" } {
      # Remove /ASF
      set uri [string range $uri 4 end]
      # Make sure we have at least a "/"
      if { $uri eq "" } { set uri "/" }
      HTTP::uri $uri
      set app_cookie "ASF"
   } elseif { $uri starts_with "/CM" } {
      # Remove /CM
      set uri [string range $uri 3 end]
      # Make sure we have at least a "/"
      if { $uri eq "" } { set uri "/" }
      HTTP::uri $uri
      set app_cookie "CM"
   } elseif { [HTTP::cookie exists AppCookie] } {
      set app_cookie [HTTP::cookie AppCookie]
   }

   switch $app_cookie {
      ASF { pool web_asfdata_pr }
      CM  { pool cmapp_asfdata_pr }
      default {
         HTTP::uri /notfound.html
         pool notfound
      }
   }
}
when HTTP_RESPONSE {
   if { $cookie_added == 0 and $app_cookie ne "" } {
      HTTP::cookie insert name "AppCookie" value $app_cookie
      set cookie_added 1
   }
}

-Joe

[Listening to: I Miss You - Incubus - Make Yourself (02:48)]