Forum Discussion
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
- Michael_Jenkins
Cirrostratus
You could use the HTTP::is_redirect command instead and see if that helps.
- Michael_Jenkins
Cirrostratus
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
event. However, you'll run into issues if it's not aHTTP_REQUEST
request (i.e. if aGET
is made). In the case of a GET, you could do this:POSTwhen HTTP_REQUEST { if { ([HTTP::method] equals "GET") && not ([string tolower [HTTP::uri]] equals [HTTP::uri]) } { HTTP::redirect [string tolower [HTTP::uri]] } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com