Forum Discussion
Combine URI::path and URI:basename in single TCL command string
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]
3 Replies
- cjunior
Nacreous
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
- markmill
Nimbostratus
The following is what I was looking for. Thanks for the assistance
tcl:[URI::path [HTTP::uri] 2][URI::basename [HTTP::uri]]- cjunior
Nacreous
Cool.
Just keep in mind you are discarding query string parameters and values.
Regards.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
