iRule - Need to skip anything after a specific string in the URI

I already have below iRule, which works good.

when HTTP_REQUEST { if { ![class match [string tolower [HTTP::uri]] contains exception_abc1_to_abc] } { if {([HTTP::uri] starts_with “/wps/portal/home/mycompany/login/!ut”) or ([HTTP::uri] starts_with “/wps/portal/home/!ut/”) } { HTTP::redirect "; } elseif {([scan [HTTP::uri] {/wps/portal/home/%s} new_uri] == 1) or ([scan [HTTP::uri] {/wps/myportal/home/%s} new_uri] == 1)} { HTTP::redirect http://wwwabc.mydomain.com/${new_uri} } } }

Now I need to add more scenarios as below to the above iRule. Can you please help ?

  1. If newURI contains “/!ut” , we need to skip everything after “/!ut”

Hi,

you can use this (I tested it and it’s working):

if { [HTTP::uri] contains "/!ui" } {    
    regexp {^(.*/!ui).*?} [HTTP::uri] -> newuri
    HTTP::uri newuri
    log local0. "AAA - $newuri"
}

Regards

you can use this:

if { [set index [string first [HTTP::uri] /!ut]] ne -1 && [string length [HTTP::uri]] > $index } {
    HTTP::redirect [string range [HTTP::uri] 0 $index]]
}