Forum Discussion
KD_48848
Nimbostratus
Aug 10, 2007URL convertion from upper case to lower case
We are currently having many redirect rules in place for one of our clients. The issue is that while redirecting we are giving conditions to match upper and lower case.
Is there any way that we can convert the URL in the first place itself.
For eg: We need to redirect http://www.abc.com/xyz to http://www.abc.com/pqr
Following redirect rule is in place:
=======
http_uri ends_with "/xyz" or http_uri ends_with "/XYZ") {
redirect to "http://www.abc.com/pqr"
}
=======
This works fine, but is there any way that we can just mention the lowercase condition and if any user hits the URL in uppercase, then it gets converted to lower case first and then matched with the above rule.
To achieve:
=======
User Enter : "http://www.abc.com/xyz" or "http://www.abc.com/xyz"
It gets converted to : "http://www.abc.com/xyz"
Then it is matched with the redirect rule :
http_uri ends_with "/xyz") {
redirect to "http://www.abc.com/pqr"
}
=======
Please any one who is aware or has worked on similar issue, advice on what is to be done.
Thanks,
KD.
10 Replies
- Deb_Allen_18Historic F5 AccountSure, the "tolower" function is what you need.
Give this a try:if (tolower(http_uri) ends_with "/xyz") { redirect to http://www.abc.com/pqr }
/deb - KD_48848
Nimbostratus
Thanks deb.
If i just mention tolower at the begining, will that convert my Uppercase to Lower case.
As in from http://WWW.ABC.COM/XYZ to http://www.abc.com/xyz and then as per the rule will redirect it to http://www.abc.com./pqr
--KD - Deb_Allen_18Historic F5 AccountWell, you're only testing the URI value, not the host header value, so it won't matter what case is used for the hostname.
If you were going to compare hostname as well in the same fashion, you'd need to wrap it in the tolower function the same way:if (tolower(http_uri) ends_with "/xyz" and tolower(http_host) equals "www.abc.com") { redirect to http://www.abc.com/pqr }
/deb - KD_48848
Nimbostratus
Cool.
Thanks Deb.
--KD - KD_48848
Nimbostratus
Hi,
The host URI is "www.abc.com" or "abc.com" or "WWW.ABC.COM" or "ABC.COM" and the above URI's are ending with "/def","/ghi", "/jkl" in both upper and lower cases etc...
We tried using the "tolower" feature but it’s supported in BigIP v9.X and we are using v4.5.X
We tried to compare the lower and upper case host_URI's and then lower and upper case ends_with conditions as follows:
To redirect "www.abc.com/def" or "WWW.ABC.COM/DEF" to "www.xyz.com/mno"
( we have similar rules in place for "/ghi", "/jkl" after the below mentioned rule)
===========
else if (http_host == "www.abc.com" or http_host == "WWW.ABC.COM" and http_uri ends_with "/def" or http_uri ends_with "/DEF") {
redirect to "www.xyz.com/mno"
}
else if (http_host == "www.abc.com" or http_host == "WWW.ABC.COM" and http_uri ends_with "/ghi" or http_uri ends_with "/GHI") {
redirect to "www.xyz.com/pqr"
}
else if (http_host == "www.abc.com" or http_host == "WWW.ABC.COM" and http_uri ends_with "/jkl" or http_uri ends_with "/jkl") {
redirect to "www.xyz.com/stu"
}
===========
But in this case, the very first condition in the rule is getting redirected as desired, but the lower two conditions are also getting redirected according the to the first condition.
So we tried comparing just the ends_with condition for lower and upper cases and keeping the host URI in lower case only, and it works as desired.
==========
else if (http_host == "www.abc.com" and http_uri ends_with "/def" or http_uri ends_with "/DEF") {
redirect to "www.xyz.com/mno"
}
else if (http_host == "www.abc.com" and http_uri ends_with "/ghi" or http_uri ends_with "/GHI") {
redirect to "www.xyz.com/pqr"
}
else if (http_host == "www.abc.com" and http_uri ends_with "/jkl" or http_uri ends_with "/jkl") {
redirect to "www.xyz.com/stu"
}
==========
We would like to know if BigIP v4.5.X also has a feature like "tolower" which is available in BigIP v9.0 and above.
If not then what is the proposed solution for this?
Thanks,
KD - KD_48848
Nimbostratus
Gonna try adding up the the parenthesis tonight.
Thanks,
KD. - KD_48848
Nimbostratus
Also can some one confirm if we can use lc() for lower case conversion in BigIPv4.5.10 ?
--KD - Deb_Allen_18Historic F5 AccountYou can use the tolower function like this:
((tolower(http_host) == "www.abc.com") and (tolower(http_uri) ends_with "/ghi"))
HTH
/deb - KD_48848
Nimbostratus
Deb that work in 4.6.x and above and we are using 4.5.X
So tolower not working :-(( - Deb_Allen_18Historic F5 Accountoops, sorry, I keep forgetting that...
/deb
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