cancel
Showing results for 
Search instead for 
Did you mean: 

Add Referer query to redirect

Johnathan
Nimbostratus
Nimbostratus

Having trouble creating an iRule to redirect URL https://example.to to test.domain.com/?__referrer=<data from referrer header>+<remainder of query string if present>

5 REPLIES 5

PeteWhite
F5 Employee
F5 Employee
when HTTP_REQUEST { set referer [ HTTP::header Referer ] if { [HTTP::query] != "" } { set RedirectUrl "https://test.domain.com/?__referrer=${referer}&[HTTP::query]" } else { set RedirectUrl "https://test.domain.com/?__referrer=${referer}" } HTTP::redirect $RedirectUrl }

This should do that for you - the typo in referer is your own

 

Thank Pete,

 

That is working now. Do you know if the referer header can do URL-encoding? Example:

referer=https://www.google.com/my_good_stuff?q=foo&bar=baz should be referrer=https%3A%2F%2Fwww.google.com%2Fmy_good_stuff%3Fq%3Dfoo%26bar%3Dbaz

 

You can use URI::encode with the set referer command which would be [ URI::encode [ HTTP::header Referer ]]

That worked perfectly. Thank you Pete!

Great!