Forum Discussion
string tolower case not working.
Hi,
i have the below irule but if any cap "uri" will not redirect correctly. I appreciate any though or input, thanks a lot.
1- this uri will redirect but not correctly https://www.abc.com/App/topic/Topic.aspx?topici=90 => https://www.xyz.com/app/Topic/Topic.aspx?topici=90
2- this uri will redirect but not correctly https://www.abc.com/app/Topics/Topic.aspx?topicid=128 => https://www.xyz.com/app/Topics/Topic.aspx?topicid=128
3- this uri will redirect correctly https://www.abc.com/app/topic/Topic.aspx?topici=128 => https://www.xyz.com/redirectlegacy/abc/app/topic/Topic.aspx?topici=128
4- this uri will redirect correctly https://www.abc.com/app/topic/topic.aspx?topici=122 => https://www.xyz.com/redirectlegacy/abc/app/topic/topic.aspx?topici=122
when HTTP_REQUEST {
if { ([string tolower [HTTP::host]] eq "www.abc.com") and ([string tolower [HTTP::uri]] starts_with "/app/topic/") } {
HTTP::redirect "https://www.xyz.com[string map {/app/topic/ /redirectlegacy/abc/app/topic/} [HTTP::uri]]"
}
}
- Stanislas_Piro2Cumulonimbus
Hi,
string tolower command does not convert HTTP::uri to lowercase but returns lowercase of HTTP::uri
So even if it matches the condition :
{ ([string tolower [HTTP::host]] eq "www.abc.com") and ([string tolower [HTTP::uri]] starts_with "/app/topic/") }
[string map {/app/topic/ /redirectlegacy/abc/app/topic/} [HTTP::uri]] will work with original HTTP::uri value.
you should change the code to this one to returns lowercase uri
when HTTP_REQUEST { if { ([string tolower [HTTP::host]] eq "www.abc.com") and ([string tolower [HTTP::uri]] starts_with "/app/topic/") } { HTTP::redirect "https://www.xyz.com[string map {/app/topic/ /redirectlegacy/abc/app/topic/} [string tolower [HTTP::uri]]]" } }
- Hien_TruongCirrus
it works perfectly with your irule. Can you quick explain "returns lowercase of HTTP::uri" how does its works? i appreciate your reply. thanks
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