Forum Discussion
Sam_Parkes_1110
Nimbostratus
Apr 10, 2007Rewrite iRule retaining part of URI
I'm trying to write an iRule that will redirect users from one URI to another - but the parameters passed in need to be retained in the redirect. However the URI is different.
I need it to receive:
http://mysite.com/maps.asp?SITEID=8&CTY=BER&PANITM=ADL&COID=2&CAT=HOT
and redirect to:
http://myredirectedsite.com/VoucherMap.aspx?SITEID=8&CTY=BER&PANITM=ADL&COID=2&CAT=HOT
I would be very grateful if someone knows how this can be done.
Many thanks,
Sam.
- Kirk_Bauer_1018
Nimbostratus
For one-off cases the replies so far are great and all you need. But if you need to do this in a general case, i.e. multiple substitutions on multiple VIPs, you can consider this rule which should be usable without modification due to its configurability: - Sam_Parkes_1110
Nimbostratus
Hi Aaron, - hoolio
Cirrostratus
I missed that you were needing to rewrite the host at the same time. Like kirkbauer noted, you can use the proxypass rule for multiple rewrites. Else for one-off changes to both the host and URI, here are updates for the examples I gave above...when HTTP_REQUEST { HTTP::header replace Host [string map {oldhost newhost} [string tolower [HTTP::host]]] HTTP::uri [string map {/maps.asp /VoucherMap.aspx} [HTTP::uri]] }
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/maps"}{ HTTP::redirect "http://[string map {oldhost/maps.asp newhost/VoucherMap.aspx} [string tolower[HTTP::host]][HTTP::uri]]" } }
- Sam_Parkes_1110
Nimbostratus
Hi Aaron,
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