Forum Discussion
Traffic redirection
" Tokenized string" [a-Z]{1,6}[0-9]{1,15} can anyone help me in writing an F5 irule for the following ?
I want to redirect the following URLs:-
1) https://sfobjtest.govnet.nsw.gov.au/id: tokenised_string 2) https://sfobjtest.govnet.nsw.gov.au/id: tokenised_string/.*
TO
tokenised_string
Hi Rakesh,
you may take the snippet below as a starting point...
when HTTP_REQUEST { if { ( [string tolower [HTTP::host]] eq "sfobjtest.govnet.nsw.gov.au" ) and ( [string tolower [HTTP::path]] starts_with "/id:" ) } then { HTTP::respond 307 Location "https://sfobjtest.govnet.nsw.gov.au:8443//documents/[findstr [HTTP::path] "/id:" 4 "/"]" } }
The iRule uses a
syntax to parse the[findstr [HTTP::path] "/id:" 4 "/"]
for the first ocourence of the string[HTTP::path]
, then skip 4 bytes (aka./id:
is skipped) and then take the remaining/id:
till the next ocourence of[HTTP::path]
./
Note: If the iRule does not work out for you, then please reply with Real-World examples of the two URLs formats that need to become redirected...
Cheers, Kai
- Rakesh_125845
Nimbostratus
Hi Kai,
I applied the irule but it doesn't seem to work.
Just this simple redirection rule doesn't work:-
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "sfobjtest.govnet.nsw.gov.au" } {
HTTP::respond 301 Location "sfobjtest.govnet.nsw.gov.au:8443//documents" } }
The URL ";
doesn't redirects to
";
Please help if possible
Hi Rakesh,
if the iRule above does not work at all, then I would recommend to include some Debug-Log line to make sure the iRule gets executed...
when HTTP_REQUEST { log local0.debug "Debug: iRule executed" if { [string tolower [HTTP::host]] equals "sfobjtest.govnet.nsw.gov.au" } { log local0.debug "Debug: [string tolower [HTTP::host]] is matching the pattern" HTTP::respond 301 Location "sfobjtest.govnet.nsw.gov.au:8443//documents" } else { log local0.debug "Debug: [string tolower [HTTP::host]] is not matching the pattern" } }
Note: Keep in mind, that almost every configuration change requires you to close any existing TCP-session. So better close/open your browser between the individual tests to get sure...
Cheers, Kai
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