Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Adding an exception to an iRule

We have an iRule we are using to remove spaces from URLs, due to some issues we were having. However, I need to adjust the iRule to allow one directory to buy pass the iRule. Here is the iRule:

when HTTP_REQUEST {
    set uri [HTTP::uri]
    set new_uri [string map {"%20" ""} $uri]
    HTTP::uri $new_uri
}

I need it to apply the rule, unless the url starts with "https://www.website.com/files";

How would I add that exception?

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Something like this:

when HTTP_REQUEST {
    if { !([string tolower [HTTP::uri]] starts_with "/files") } {
        set uri [HTTP::uri]
        set new_uri [string map {"%20" ""} $uri]
        HTTP::uri $new_uri
    }
}
0
Comments on this Answer
Comment made 22-Feb-2018 by SteveEason 68

Ok, I see. I appreciate the input!

0
Comment made 22-Feb-2018 by SteveEason 68

It does give an error that it's missing a bracket.

01070151:3: Rule [/Common/Percet20_sans_Files] error: /Common/Percet20_sans_Files:2: error: [parse error: PARSE missingBracket 31 {missing close-bracket}][{ !([string tolower [HTTP::uri] starts_with "/files") }]

0
Comment made 22-Feb-2018 by Niels van Sluis 2744

Yes, I just updated the example :-)

0
Comment made 22-Feb-2018 by SteveEason 68

Thanks, that fixed it. :)

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
if {not([HTTP::uri] starts_with "/files")} {
do stuff
}
0