Forum Discussion
Johnathan
Nimbostratus
Jan 17, 2020Add Referer query to redirect
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>
- PeteWhite
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
- Johnathan
Nimbostratus
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
- PeteWhite
Employee
You can use URI::encode with the set referer command which would be [ URI::encode [ HTTP::header Referer ]]
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects