30-Aug-2023 13:24
I have two rules that work on there own, not sure how to combine them into one.
when HTTP_REQUEST {
set HOST [string tolower [HTTP::host]]
set TOKEN [getfield [HTTP::uri] "/?r=" 2]
HTTP::respond 302 Location "https://www2.google.com/gui/reloan/getstarted?code=$TOKEN" Connection Close
}
when HTTP_REQUEST {
set HOST [string tolower [HTTP::host]]
set TOKEN [getfield [HTTP::uri] "/" 2]
HTTP::respond 302 Location "https://www1.google.com/ShortUrlLanding/?lmco=$TOKEN" Connection Close
}
Solved! Go to Solution.
31-Aug-2023 21:27 - edited 31-Aug-2023 21:33
@F5workuserguy I'm not understanding the tinyURL piece because I was under the impression that the tinyURL service is what mapped to your URL for you and then you receive the full intended request. Can you provide an example of what each request would look like when it arrives to your F5 so we can formulate an iRule that will handle the request? For now you might try the following and see if that works for your purposes. I removed you creation of the HOST variable because you were not using it so it isn't necessary.
when HTTP_REQUEST priority 500 {
if { [HTTP::uri] contains "/?r=" } {
set TOKEN [getfield [HTTP::uri] "/?r=" 2]
HTTP::respond 302 Location "https://www2.google.com/gui/reloan/getstarted?code=${TOKEN}" Connection Close
} else {
set TOKEN [getfield [HTTP::uri] "/" 2]
HTTP::respond 302 Location "https://www1.google.com/ShortUrlLanding/?lmco=${TOKEN}" Connection Close
}
}
30-Aug-2023 21:19
@F5workuserguy Will either "/" or "/?r=" always exist? Will the token always be a certain length and character variation?
31-Aug-2023 09:06
I first setup the "/" for tinyURL redirection, but was just informed they want to send a new tinyURL with "/?r=" anyways in front of the URI string.
31-Aug-2023 11:34
@F5workuserguy If you're changing to "/?r=" then no need to have both running at the same time.
31-Aug-2023 13:43
they are still going to have both rolling in that need to get redirected. I was hoping to get something for catching "/?r=" first, then the default "/" for the rest.
31-Aug-2023 21:27 - edited 31-Aug-2023 21:33
@F5workuserguy I'm not understanding the tinyURL piece because I was under the impression that the tinyURL service is what mapped to your URL for you and then you receive the full intended request. Can you provide an example of what each request would look like when it arrives to your F5 so we can formulate an iRule that will handle the request? For now you might try the following and see if that works for your purposes. I removed you creation of the HOST variable because you were not using it so it isn't necessary.
when HTTP_REQUEST priority 500 {
if { [HTTP::uri] contains "/?r=" } {
set TOKEN [getfield [HTTP::uri] "/?r=" 2]
HTTP::respond 302 Location "https://www2.google.com/gui/reloan/getstarted?code=${TOKEN}" Connection Close
} else {
set TOKEN [getfield [HTTP::uri] "/" 2]
HTTP::respond 302 Location "https://www1.google.com/ShortUrlLanding/?lmco=${TOKEN}" Connection Close
}
}
01-Sep-2023 10:38
01-Sep-2023 15:31
update, I changed
contains to starts_with