URI Matching when URI contains a space

I am using version 11.2 and in the name of full disclosure, I am an iRules noobie.

I am trying to match a specific URI but the URI has a space in the name “common files”. When I use the code below it does not match requests that I would expect it to.

([string tolower [HTTP::uri]] starts_with “/common files”)

What is the proper way to reference a space in a URI? Would I need to use %20 in the URI? Something like this --

([string tolower [HTTP::uri]] starts_with “/common%20files”)

Thank you!

I’d imagine it would indeed be %20. You could modify the iRule to have this decoded or simply add the %20. It might be worth adding 'log local0. “URI is [HTTP::uri]” just to check. Anyway, to do the decoding, try this;

[URI:decode [string tolower [HTTP::uri]]] starts_with "/common files"

Great, thank you!

You’re welcome. Have you actually tried it?

e.g.

[root@ve11a:Active:Changes Pending] config  tmsh list ltm rule myrule
ltm rule myrule {
    when HTTP_REQUEST {
   log local0. "\[HTTP::uri\] [HTTP::uri]"
   log local0. "\[string tolower [HTTP::uri]\] [string tolower [HTTP::uri]]"
   log local0. "\[URI::decode [string tolower [HTTP::uri]]\] [URI::decode [string tolower [HTTP::uri]]]"
}
}
[root@ve11a:Active:Changes Pending] config  cat /var/log/ltm
Apr 30 11:08:11 ve11a info tmm[8163]: Rule /Common/myrule : [HTTP::uri] /common%20files
Apr 30 11:08:11 ve11a info tmm[8163]: Rule /Common/myrule : [string tolower /common%20files] /common%20files
Apr 30 11:08:11 ve11a info tmm[8163]: Rule /Common/myrule : [URI::decode /common%20files] /common files