Forum Discussion

javier_diaz_379's avatar
Icon for Nimbostratus rankNimbostratus
Sep 16, 2011

how to lower a part of the URI?

Lets say I have


I need an irule to only lower the firs part of the URI. In the case I need a 301 redirect to


How can I do that?


4 Replies

  • If you know what the first part of the URI is, then it isn't so bad. You can grab everything after that first part of the URI with this:



    set newURI [string range [HTTP::uri] 4 end] this trims off /Bar (4 characters, you can change that value to reflect your actual URI)



    Now, you can redirect to$newURI.



    If the first part of the URI isn't always known, it's still possible but more work.
  • please feel free to revise.

    [root@orchid:Active] config  b virtual bar80 list
    virtual bar80 {
       ip protocol tcp
       rules myrule1
    [root@orchid:Active] config  b rule myrule1 list
    rule myrule1 {
       when HTTP_REQUEST {
            scan [HTTP::uri] {/%[^/]%s} para1 para2
            HTTP::redirect "http://[HTTP::host]/[string tolower $para1]$para2"
    [root@orchid:Active] config  curl -I
    HTTP/1.0 302 Found
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
  • Brian_Deitch_11's avatar
    Historic F5 Account
    You can grab the 1st folder dynamically regardless of the the length:

    set para1 [string tolower [URI::path [HTTP::uri] 1 1]]