Forum Discussion
Brian_Kenworthy
Aug 30, 2012Nimbostratus
Redirect 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
- Kevin_StewartEmployeeSomething like this should work:
- Brian_KenworthyNimbostratusThanks 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_YatesNimbostratusHi 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_KenworthyNimbostratusThanks 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_YatesNimbostratusHi Brian,
- hooleylistCirrostratusAre 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_KenworthyNimbostratusThanks 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.
- hooleylistCirrostratusCan you try string map -nocase to do a case insensitive replacement?
- Brian_KenworthyNimbostratusWorking like a charm, thanks so much again all for the help. I really appreciate it!
- Brian_KenworthyNimbostratusActually, 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