Forum Discussion
Brian_Kenworthy
Nimbostratus
Aug 30, 2012Redirect to New Page but Pass Query String Parameters
Hi All,
Need some advice on what an iRule would look like to do this....We are moving from legacy ASP listeners to .net listeners, but we don't want the client to change their endpoint until they are ready. So here's what it we are looking to do:
redirect requests destined for:
https://my.domain.com/vendor/status.asp?user=xxx&password=yyy
to
https://my.domain.com/vendor/status.aspx?user=xxx&password=yyy
I know how to redirect the whole URI, but am confused about how to change just one piece:
when HTTP_REQUEST {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
Thanks for your help in advance!!
BK
12 Replies
Sort By
- Kevin_Stewart
Employee
Something like this should work: - Brian_Kenworthy
Nimbostratus
Thanks for the quick response Kevin! I like the transparent method, that's even better then a redirect. We don't what the client to see anything :) - Michael_Yates
Nimbostratus
Hi Brian,when HTTP_REQUEST { if { [HTTP::uri] contains "vendor" && [HTTP::uri] contains ".asp?" } { set uri [string map {"vendor" "listeners" ".asp?" ".aspx?"} [HTTP::uri]] HTTP::redirect "https://[HTTP::host]$uri" } }
- Brian_Kenworthy
Nimbostratus
Thanks all, I tested out each of the suggestions and it appears to be working great. One thing I wanted to do was log the original URI and the re-written URI, but I can't seem to be able to use HTTP::URI with HTTP_RESPONSE. It's probably something very simple.... - Michael_Yates
Nimbostratus
Hi Brian, - hoolio
Cirrostratus
Are you trying to log the updated URI value? In pre-v11.0, the HTTP::uri was cached in the same event. So you could use something like this: - Brian_Kenworthy
Nimbostratus
Thanks Aaron, that is exactly what I was looking for. Michael, I tried looking at the HTTP::header location field and I wasn't seeing the new URL in the location field, not sure if I had it correct. - hoolio
Cirrostratus
Can you try string map -nocase to do a case insensitive replacement? - Brian_Kenworthy
Nimbostratus
Working like a charm, thanks so much again all for the help. I really appreciate it! - Brian_Kenworthy
Nimbostratus
Actually, I have another wrinkle to add...here's the code we're using and what is happening. Also note I had to replace the " " with {} per a configsync issue (http://support.f5.com/kb/en-us/solutions/public/12000/700/sol12795.html)
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