Forum Discussion

François_Bégin_'s avatar
François_Bégin_
Icon for Nimbostratus rankNimbostratus
Jul 18, 2005

Search and replace in HTTP::uri

Once more unto the breach, as they say...

 

 

I have some application people that want me to do the following:

 

 

Type http://banana.fruits.com/ASF in a brower and you get re-directed to ip 10.10.1.1:1601. On that port, a web server is listening. The web server does *not* have an ASF subdirectory. Basically, you should be hitting the default page of the web server, in this case, a login page.

 

 

Type http://banana.fruits.com/ASF/connector.htm and you get re-directed to ip 10.10.1.1:1601 where you will be requesting file 'connector.htm' (again ASF gets nixed).

 

 

How can this be done? I posted earlier and got some ideas which I tried. The application people are not satisfied with what I have achieved so far. I had them create a soft link called ASF in their document root and pointing to the document root (ln -s . ASF) but they are unhappy with this easy fix.

 

 

Is there a specific irule function that will search HTTP::uri and replace 'ASF' with an empty string? That would solve my problem. The closest I got was

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] starts_with "/ASF" } {

 

HTTP::uri "/"

 

pool app_asfdata_dv

 

}

 

 

But that replaces '/ASF/anything' with '/'. It works great for the default page but fails for something like /ASF/connector.htm

 

 

1 Reply

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    How about this slight enhancement to what you already have:

    
    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
          pool app_asfdata_dv
       }
    }