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

jmartinez_44554's avatar
jmartinez_44554
Icon for Nimbostratus rankNimbostratus
Aug 21, 2015

Need to replace middle of URL

I need to replace the middle of this url and some others.

 

http://test.host.com/Library/content/en/Integrators-v1/GUID-7CDA266F-3924-4B28-A026-3092CDB17E7B

 

Needs to be

 

http://test.host.com/Library/content/en/product-v2/GUID-7CDA266F-3924-4B28-A026-3092CDB17E7B

 

I'm using this code and its not firing.

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/library/content/en/integrators-v1/" { set newURI [string map -nocase {"/Library/content/en/Integrators-v1/" "/Library/content/en/product-v2/"} [HTTP::uri]] log local0. "redirecting to http://[HTTP::host]$newURI" HTTP::redirect "http://[HTTP::host]$newURI" } } }

 

1 Reply

  • You're missing the wildcard on the end of your URI evaluation:

    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::uri]] { 
            "/library/content/en/integrators-v1/*" { 
                set newURI [string map -nocase {"/Library/content/en/Integrators-v1/" "/Library/content/en/product-v2/"} [HTTP::uri]] 
                log local0. "redirecting to http://[HTTP::host]$newURI" 
                HTTP::redirect "http://[HTTP::host]$newURI" 
            } 
        } 
    }