Forum Discussion
javier_diaz_379
Nimbostratus
Mar 03, 2011URL to lower string
I need to know, how to make an iRule to translate the complete URL to lower string and then do the redirect.
I have the idea of how to make that happend, but this irule is not working.
when HTTP_REQUEST{
set location [string tolower [HTTP::uri]]
HTTP::redirect "http://[HTTP::host][$location]
}
5 Replies
- hoolio
Cirrostratus
That looks okay. You're missing a closing double quote on the redirect. You could also eliminate the intermediate variable:when HTTP_REQUEST { HTTP::redirect "http://[HTTP::host][string tolower [HTTP::uri]]" }
Aaron - hoolio
Cirrostratus
Also, if you're doing that for every request and this is on an HTTP virtual server, you'll get a redirect loop. You could try something like this:when HTTP_REQUEST { Check if the URI has any capitalized letters if {[string match {*[A-Z]*} [HTTP::uri]]}{ HTTP::redirect "http://[HTTP::host][string tolower [HTTP::uri]]" } }
Setting parameter names or values to lower case might actually break the web app parsing of them. Do you want to set the path or the full URI to lower case (/path/to/file.ext versus /path/to/file.ext?param=value)?
Aaron - javier_diaz_379
Nimbostratus
Great, it works!
It will be a great idea to setup this to work with parameters.
Just to be sure, the way to do it is this?
when HTTP_REQUEST {
Check if the URI has any capitalized letters
if {[string match {*[A-Z]*} [HTTP::uri]]}{
HTTP::redirect "http://[HTTP::host][string tolower [HTTP::path]]?[HTTP::query]"
}
} - hoolio
Cirrostratus
Just one update if you only want to check the path:when HTTP_REQUEST { Check if the URI has any capitalized letters if {[string match {*[A-Z]*} [HTTP::path]]}{ HTTP::redirect "http://[HTTP::host][string tolower [HTTP::path]]?[HTTP::query]" } }
Aaron - javier_diaz_379
Nimbostratus
Ok! I forgot to do that change
Thank you!
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
