Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 
Custom Alert Banner

string tolower case not working.

Hien_Truong
Cirrus
Cirrus

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]]"

  }

}

2 REPLIES 2

Stanislas_Piro2
Cumulonimbus
Cumulonimbus

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_Truong
Cirrus
Cirrus

it works perfectly with your irule. Can you quick explain "returns lowercase of HTTP::uri" how does its works? i appreciate your reply. thanks