Forum Discussion
How to remove from path first segment on F5
Hello I have problem to implement solution as above in topic.
I have URL: https://1234.com/en-gb/cat/dog and I want from path remove first segment "en-gb" and put rest of the path to redirect
when HTTP_REQUEST {
if { ([string tolower [HTTP::path]] starts_with "/en-gb")
HTTP::redirect "https://zoo.com/london/en-gb/apps/tickets [string tolower [URI::path [HTTP::uri] 2]]"
}
}
Problem is that URI::path is not working and F5 probably is not reading it as function (HTTP has purple color, so it is correct).
Is it possible to do it in different way to manipule segments belong to path variable?
- Simon_Blakely
Employee
Well, you have a problem with the syntax of the if conditional, so this breaks the parsing of the TCL and the syntax highlighting.
Also, your HTTP::redirect target is wrong - you will end up with a space in the location, which is not legal.
As always, start with some logging ...
when HTTP_REQUEST { log local0. "path is [string tolower [HTTP::path]]" if { ([string tolower [HTTP::path]] starts_with "/en-gb") } { log local0. " uri is [string tolower [HTTP::uri]], path from 2nd element is [string tolower [URI::path [HTTP::uri] 2]]" HTTP::redirect "https://1234.com/london/en-gb/apps/tickets[string tolower [URI::path [HTTP::uri] 2]]" } }
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