30-May-2020 06:19
I have a uri /dir1/dir2/dir3/filename.ext where I would like to replace/strip the first directory e.g. /dir2/dir3/filename.ext before forwarding on the request. I have been using the following, but I'm struggling with how to pass the URI::basename along as well. I'm looking for a single TCL command string that I can use within my LTM traffic policy.
tcl:[URI::path [HTTP::uri] 2]
04-Jun-2020 13:06
Hi,
Is the /dir1 a fixed name?
If so, you can simply skip that name length:
tcl:[string range [HTTP::uri] 5 end]
Otherwise, you can work with variables or try this single line:
tcl:[URI::path [HTTP::uri] 2][URI::basename [HTTP::uri]][expr { \"[URI::query [HTTP::uri]]\" eq {} ? {} : \"?[URI::query [HTTP::uri]]\" }]
I hope it helps.
Regards
09-Jun-2020
06:38
- last edited on
24-Mar-2022
01:17
by
li-migration
The following is what I was looking for. Thanks for the assistance
tcl:[URI::path [HTTP::uri] 2][URI::basename [HTTP::uri]]
09-Jun-2020 11:03
Cool.
Just keep in mind you are discarding query string parameters and values.
Regards.