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

Grayson_149410's avatar
Grayson_149410
Icon for Nimbostratus rankNimbostratus
Jan 26, 2015

iRule Different HTTP Response and lower string

I have the following iRule that works great for 302 to 301 redirects and lowers the uri.

 

The problem I am running into now that if it returns a status other than 302 (for example a simple 200 return) it does not lowercase the uri.

 

Here is my code that works great. I would like it to send on any other response, but to lowercase everything.

 

when HTTP_RESPONSE {
if {[HTTP::status] == 302}{
    HTTP::respond 301 Location "[string tolower [HTTP::header Location]]"
}

}

 

2 Replies

  • Can I ask what your use case is for lowercase uri? If you only care about the uri on the serverside, then you can just do this:

    when HTTP_REQUEST {
        HTTP::uri [string tolower [HTTP::uri]]
    }
    

    If you need the client to see the lowercase URI in their browser, then you'll need to issue a redirect in the

    HTTP_REQUEST
    event. However, you'll run into issues if it's not a
    GET
    request (i.e. if a
    POST
    is made). In the case of a GET, you could do this:

    when HTTP_REQUEST {
        if { ([HTTP::method] equals "GET") && not ([string tolower [HTTP::uri]] equals [HTTP::uri]) } {
            HTTP::redirect [string tolower [HTTP::uri]]
        }
    }