Forum Discussion

sampoudel11_343's avatar
sampoudel11_343
Icon for Nimbostratus rankNimbostratus
Dec 08, 2017

http redirection for the URLs with wildcard

Hi I am trying to create the redirection iRule that will redirect wildcard.123.abc.com/wildcard to wildcard.123.xyz.com/wildcard. I created the following iRule and I think the logic is ok. But, I do not know if I have the syntax error or anything I am not able to upload the iRule to the f5.

 

when HTTP_REQUEST { if { [HTTP::host] contains "123.abc.com" } { set host [string map {"123.abc.com" "123.xyz.com"} [getfield [HTTP::host] ":" 1]] HTTP::redirect "http://$host[HTTP::uri]" } }

 

So, when I try to upload the iRule in the F5 I get the following error.

 

Definition 01070151:3: Rule [/partition/irulename] error: /partition/irulename:2: error: [undefined procedure: &160][ ]

 

Could you please suggest me if I am doing anything wrong or if you could suggest the completely new iRule that will do the redirection for the URL I mentioned above.

 

Thank you Sam

 

1 Reply

  • I don't understand what you are trying to do with string map. Try this code:

     

    when HTTP_REQUEST {     
        if { [HTTP::host] equals "123.abc.com" } {             
             HTTP::redirect "http://123.xyz.com[HTTP::uri]"             
        }       
    }