For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Emad's avatar
Emad
Icon for Cirrostratus rankCirrostratus
Jul 31, 2013

Irule replace specific URI

I need replace a set if URI from my URL with single one.

 

e.g

 

I have these URLs which are being used now

 

www.123.com/app/cs/aaa,jsp

 

www.123.com/app/cs/bbb,jsp

 

www.123.com/app/cs/ccc,jsp

 

what i want is that when ever there is a set of uri i.e "/app/cs/" in URL that should be switch to "/cas"

 

and new urls should be

 

 

www.123.com/cas/aaa,jsp

 

www.123.com/cas/bbb,jsp

 

www.123.com/cas/ccc,jsp

 

2 Replies

  • 
    when HTTP_REQUEST {
        log local0. "Incoming URI = [HTTP::uri]"
        if { [string tolower [HTTP::uri]] starts_with "/app/cs" } {
            set uri [string map -nocase {"/app/cs" "/cas"} [HTTP::uri]]
            log local0. "New URI = $uri"
            HTTP::uri $uri
        }
    }
    

    ** disable the logging statements once you've verified correct operation.

    Also note that this transparently changes the request URI on ingress traffic (the client browser does not see the change). If you need to change "/app/cs" instances in outgoing payload (headers, redirects, object references), then a STREAM profile iRule is in order.

  • I wrote the next irule:

     

    when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/swscersalud" {

     

    pool Pool_Consorcio_test set VARIABLE[string map -nocase {"/swscersalud/wscersalud.asmx" "/Services/Utility/certificacionSalud/WS/Implementation/Service.serviceagent/WSCERSALUDSoapEndpoint"} [HTTP::uri]] HTTP::uri $VARIABLE log local0. "Ingreso al swscersalud [HTTP::uri]" } "/wsconadmo" { log local0. "Ingreso al wsconadmo [HTTP::uri]" set VARIABLE[string map -nocase {"/Wsconadmo/OyS.asmx" "/Services/Utility/OyS/WS/Implementation/WSCONADMO.serviceagent/OySSoapEndpoint"} [HTTP::uri]] HTTP::uri $VARIABLE pool Pool_Consorcio_test_V2 } } }

     

    when HTTP_REQUEST_SEND { switch [LB::server addr] { "10.237.146.1" { HTTP::header replace Host "vmpesbserver:14002" } "10.237.146.2" { HTTP::header replace Host "vmpesbserver2:14002" } }

     

    }

     

    Is this right?