cancel
Showing results for 
Search instead for 
Did you mean: 

URI::path returns null without trailing slash (/)

SteveBy5
Nimbostratus
Nimbostratus

Hi,

I'm trying to workout some redirects based on the first level of the URI path.

set rPath [string tolower [URI::path [HTTP::uri] 1 1]]

when I hit the iRule with "https://something.com/path1/"  I get "/path1/".  But if I hit it with "https://something.com/path1" I get nothing and my switch statement fails if I try and match "/path1".  If I forget the path and just do HTTP::uri it works, but of course I could end up with more than just the first level (right?).

However, in a different iRule which does this:

set NEW_URL [class match -value $rPath equals MYDATAGROUP]

and that seems works.  I'm on LTM v14 and I'm a little confused.

I'd appreciate any advise at all.

1 REPLY 1

Hello @SteveBy5,

You have a great explanation of how URI::path works.

https://clouddocs.f5.com/api/irules/URI__path.html

Anyway, in your case you can use something like this:

[HTTP::uri starts_with "/path1"]

 

Regards,
Dario.