Forum Discussion
irule for lower case of uri
Dear Members,
I have below mentioned code for which there is one confusion to implement the code for lower case. Issue is i need to redirect entire url / uri or query with lower case letter. e.g if someone types MyLocalNet.Net/Fr/PaGes/Default it should be lower case mylocalnet.net/fr/pages/default etc. Appreciate your support. Thanks.
when HTTP_REQUEST { / tell server not to compress response
/ HTTP::header remove Accept-Encoding
/ disable STREAM for request flow
STREAM::disable
/ redirect discnet requests to discnet site
if { [string tolower [HTTP::path]] equals "/" } {
if { [HTTP::header "Accept-Language"] starts_with "fr" } {
HTTP::respond 301 "Location" "https://www.mylocalnet.net/fr/pages/default.aspx"} elseif { [HTTP::header "Accept-Language"] starts_with "en" } { HTTP::respond 301 "Location" "https://www.mylocalnet.net/en/pages/default.aspx" } } elseif { [string tolower [HTTP::path]] equals "/discnet/discnet.xml" } { HTTP::respond 301 "Location" "https://discnet.mylocalnet.net/discnet/discnet.xml"
} elseif { [HTTP::path] contains "/sub-catagories/" } { HTTP::respond 301 noserver Location "https://[HTTP::host][string map -nocase {sub-catagories sub-catagaries} [HTTP::path]]"
} elseif { [HTTP::path] contains "/health-blog/" } { HTTP::respond 301 noserver Location "https://[HTTP::host][string map -nocase {net-blog net-let} [HTTP::path]]"
} elseif { [string tolower [HTTP::uri]] equals "/en/testing.xml" } { HTTP::uri "/en-testing.xml" } elseif { [string tolower [HTTP::path]] equals "/fr/testing.xml" } { HTTP::uri "/fr-testing.xml"
} }
7 Replies
- Josiah_39459Historic F5 Account
[string tolower "MiXeD cAsE"] (returns "mixed case") is what you want. You already have it in your irule in some places but not others.
- Jeff_Denny_2552
Nimbostratus
Thanks Josiah for your inputs. Kindly if you could help to update the above mentioned code with the recommended one so that i test it ? - Jeff_Denny_2552
Nimbostratus
Dear team will appreciate your valuable inputs. - Ralph_David_201
Nimbostratus
Hi Members, I am still confused on the syntax. Can someone help me to correct the code to keep all uri/urls in this code to be always lower case ?
You're pretty close to having what you want. I recommend checking out the following series of articles, which can provide you with the tools needed when working with iRules. Once you have the basics down, they are very powerful.
https://devcentral.f5.com/articles/-the101-irules-101-introduction-to-programming-amp-tcl?tag=101
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
