21-Jan-2021 05:38
Old website will be decommissioned and we want users that would access the old site to be redirected but with the original URL be added and a referrer in the header. Can the original URL can be passed as either a HTTP GET parameter or as a HTTP header, but the referrer should stay “hidden” and be passed in a HTTP header?
We'd like F5 to put the original URL and the referrer into GET parameters.
For example, a user goes to OLD-APP and clicks on help button.
OLD-APP: http://old-app.com/URI/query
help link: http://old-app.com-help/URI/query
F5 intercepts and returns HTTP 301 with the following headers:
Location: https://NEW-APP.com/redirect/?url=http%3A%2F%2Fold-app.com-help%2FURI%2Fquery&referer=http%3A%2F%2Fold-app.com%2FURI%2Fquery
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
If there is no Referrer header, then F5 can omit referrer or just use an empty value (i.e. referrer=).
We are trying to achieved this via an iRule, I've looked around and found some iRule that could potentially helped but I cant create a specific iRule for this requirements. I'd appreciate your help. TIA.
23-Jan-2021 09:01
Hi,
Could you give this a try:
when HTTP_REQUEST {
HTTP::respond 301 Location "https://NEW-APP.com/redirect/?url=http://[HTTP::host][HTTP::uri]" Referer "http://[HTTP::host][HTTP::uri]"
}
Cheers,
Kees
27-Jan-2021 06:03
Thanks Kees.
I got it to work but app owner says that they are seeing below,
Location: https://https://NEW-APP.com/redirect?url=http://old-app.com-help/URI/URI1/URI2/URI3
Instead of this,
Location: https://NEW-APP.com/redirect/?url=http%3A%2F%2Fold-app.com%2FURI%2FURI1%2FURI2%2FURI3
They also want to have a cache-control header
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Also the referrer does not seem to work as F5 doesn't include the referrer in the redirect URL.
TIA.
27-Jan-2021
06:32
- last edited on
21-Nov-2022
16:20
by
JimmyPackets
Hi TIA,
Can you post the irule here?
Cache control header is not a request but a response header. So this can not be included in a redirect.
You need separate code in the irule:
when HTTP_RESPONSE {
if { [HTTP::header value Content-Type] contains "application/pdf" } {
HTTP::header replace Pragma public
HTTP::header replace Cache-Control public
}
elseif { [HTTP::header value Content-Type] contains "application/vnd.ms-excel" } {
HTTP::header replace Pragma public
HTTP::header replace Cache-Control public
}
elseif { [HTTP::header value Content-Type] contains "application/msword" } {
HTTP::header replace Pragma public
HTTP::header replace Cache-Control public }
else {
return
}
}
27-Jan-2021 08:44
Hi,
This is what i currently have but it does not seem to be working. I used the iRule that you suggested but ended up modifying it as it is not working according to their requirements and so that's the end result.
when HTTP_REQUEST {
set uri [URI::encode [HTTP::uri]]
set host [URI::encode [HTTP::host]]
set referer [URI::encode [ HTTP::header Referer ]]
if { [string tolower [HTTP::uri]] starts_with "/URI/"} {
HTTP::respond 301 Location "https://NEW-APP.com/redirect/?url=http://$(host)$(uri)__referrer=${referer}&[HTTP::query]" { HTTP::header replace "Cache-Control" "no-store, no-cache, must-revalidate, max-age=0" }
}
}
28-Jan-2021 03:02
Hi,
Can you test this irule?
when HTTP_REQUEST {
set uri [URI::encode [HTTP::uri]]
set host [URI::encode [HTTP::host]]
set referer [URI::encode [ HTTP::header Referer ]]
if { [string tolower [HTTP::uri]] starts_with "/uri/"} {
HTTP::respond 301 Location "https://NEW-APP.com/redirect/?url=http://$host$uri\_\_referrer=$referer\&[HTTP::query]" Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
}
}
Cheers,
Kees
02-Feb-2021 08:08
Perfectly works...Thanks Kees.
01-Aug-2022 22:20
What about something like this?
Redirect TLS 1.1/1.2 clients & Append the incoming... - DevCentral (f5.com)