Irule exclude url and redirect problem

Origianal Irule as below will filter “/support” string, I want add another one but looks like it’s not working. I appreciate if anyone can help :slight_smile:

when HTTP_REQUEST { if { not ([string tolower [HTTP::uri]] starts_with “/support”) } { HTTP::respond 301 Location “http://www.test.com” } }

I changed as below:

when HTTP_REQUEST { if { not ([string tolower [HTTP::uri]] starts_with “/support”) or not ([string tolower [HTTP::path]] equals “/about-uss/sage-trustwave-pci-compliance” ) } { HTTP::respond 301 Location “http://www.test.com” } }

Hi Paulguo,

try this snipped…

set low_uri [string tolower [HTTP::uri]]
if {( $low_uri starts_with "/support") or 
    ( $low_uri equals "/about-uss/sage-trustwave-pci-compliance" ) 
} then { 
    Do nothing
} else {
    HTTP::respond 301 Location "http://www.test.com" 
}

Cheers, Kai

Hi Paulguo,

try this snipped…

set low_uri [string tolower [HTTP::uri]]
if {( $low_uri starts_with "/support") or 
    ( $low_uri equals "/about-uss/sage-trustwave-pci-compliance" ) 
} then { 
    Do nothing
} else {
    HTTP::respond 301 Location "http://www.test.com" 
}

Cheers, Kai

Hi Paulguo,

if you want to avoid the empty “then” clause, then try this snipped…

set low_uri [string tolower [HTTP::uri]]
if { not (
            ( $low_uri starts_with "/support") or 
            ( $low_uri equals "/about-uss/sage-trustwave-pci-compliance" )
    ) 
} then { 
    HTTP::respond 301 Location "http://www.test.com" 
}

BTW: Using the first or second example only depends on your prefered coding style, while providing the same functionality without any noticable performance impacts/gains^^

BTW2: Putting the low_uri into a variable will save some CPU cycles if evaluated more than once^^

HTH, -Kai

Thank you Wilke, I will test on my device.