Forum Discussion
iRule to change the URL hostname and path, but nothing else
I need to write an iRule that will redirect the browser from this:
http://server1/fubarpath/AMSDocViewer.asp?DocID=626527942&Rev=1
to this:
http://server2/apppath/ImageEnablingLauncher.aspx?DocID=626527942&Rev=1
The main point is that I need to retain the ? character and everything to the right of it.
[HTTP::uri] seems to be important here, that grabs everything after the hostname. I only need part of that. "string map" could maybe be used to provide a list of things to be changed in the URL, thus keeping the part I need to keep, but I don't know how to put it all together.
- Josiah_39459Historic F5 Account
HTTP::path
and
HTTP::query
are your friends
https://devcentral.f5.com/wiki/iRules.HTTP__path.ashx https://devcentral.f5.com/wiki/iRules.HTTP__query.ashx
- Stanislas_Piro2Cumulonimbus
Try this:
when HTTP_REQUEST { if {([HTTP::path] equals "/fubarpath/AMSDocViewer.asp") && ([HTTP::host] equals "server1")} { HTTP::respond 302 noserver Location "http://server2/apppath/ImageEnablingLauncher.aspx?[HTTP::query]" } }
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