23-Aug-2021 14:34
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]]"
}
}
24-Aug-2021
01:56
- last edited on
21-Nov-2022
16:06
by
JRahm
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]]]"
}
}
24-Aug-2021 09:59
it works perfectly with your irule. Can you quick explain "returns lowercase of HTTP::uri" how does its works? i appreciate your reply. thanks