For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

cwdusheke's avatar
cwdusheke
Icon for Nimbostratus rankNimbostratus
Jan 23, 2020
Solved

irule - converting if to switch

I am trying to convert my irule from using the if to the switch. Here' s an email of my old irule.   when HTTP_REQUEST { if { (([HTTP::host] contains "abc1.com") && ([HTTP::uri] == "/" )) }{ ...
  • Dario_Garrido's avatar
    Jan 23, 2020

    Hello.

    Try this:

    when HTTP_REQUEST {
    	switch -glob [string tolower [HTTP::host]] {
    		"*abc1.com" {
    			if { [HTTP::uri] eq "/" } {
    				HTTP::uri "/tf/myPLAN/SponsorWelcome?cz=123456789"
    			}
    		}
    		"*abc2.com" {
    			if { [HTTP::uri] eq "/" } {
    				HTTP::uri "/tf/myPLAN/SponsorWelcome?cz=223456789"
    			}
    		}
    		"*example1.com" {
    			HTTP::respond 301 Location "https://example11.com"
    		}
    		"*example2.com" {
    			HTTP::respond 301 Location "https://example22.com"
    		}
    	}
    }

    KR,

    Dario.