Forum Discussion
briancapps_1029
Nimbostratus
Sep 21, 2010iRule redirect - change domain, path but keep unique ID
I'm having trouble getting an iRule right that redirects domain, modifies path, but maintains a trailing unique identifier. I intend to redirect:
http://documents.test.com/retrieve.asp?guid=43w232w398s-sd
to
http://platform.test.com/Servicepages/RetrieveDocument.aspx?did=43w232w398s-sd
Where the value after the = will always be variable.
Thoughts?
- briancapps_1029
Nimbostratus
Here's my shot at it so far. It's just not working the way I would hope. Seems to ignore the host redirect and the uri string map as well.
if {[HTTP::host] equals "documents.test.com"} {
if { [HTTP::uri] starts_with "/retrieve.asp?guid"}{
- briancapps_1029
Nimbostratus
Ok, got it figured out, in case this helps anyone and so nobody wastes any time with it... - Lambera_53322
Nimbostratus
Ive been directed to take over this project for Capps since he has left the business. This is still an open question and his solution does not work. - Lambera_53322
Nimbostratus
Well it looks like he was pretty close to a solution as the following works but with some minor issues: - Colin_Walker_12Historic F5 AccountIt sounds like you need the string tolower command. For a case insensitive comparison try:
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/retrieve.asp"}{ HTTP::redirect "http://[string map {".../retrieve.asp?guid=" ".../Servicepages/RetrieveDocument.aspx?did="} [string tolower [HTTP::host]][HTTP::uri]]" } }
- Lambera_53322
Nimbostratus
Thanks, I tried your sugestion but this seems to throw this into an infinate loop when accessing links that have a upper R in the asp page. - hoolio
Cirrostratus
Can you try this instead?when HTTP_REQUEST { Check for requests to /retrieve.asp if { [string tolower [HTTP::path]] eq "/retrieve.asp"}{ Redirect the request to /Servicepages/RetrieveDocument.aspx with the guid parameter value set as did HTTP::redirect "/Servicepages/RetrieveDocument.aspx?did=[URI::query "?&[HTTP::query] &guid]" } }
- Lambera_53322
Nimbostratus
line 8: [parse error: missing close-bracket] [[URI::query "?&[HTTP::query] &guid]" - Michael_Yates
Nimbostratus
Can you try this:when HTTP_REQUEST { Check for requests to /retrieve.asp if { [string tolower [HTTP::path]] eq "/retrieve.asp"}{ Redirect the request to /Servicepages/RetrieveDocument.aspx with the guid parameter value set as did HTTP::redirect "/Servicepages/RetrieveDocument.aspx?did=[URI::query [HTTP::query] "guid" ]" } }
- hoolio
Cirrostratus
Sorry, there was a missing double quote:when HTTP_REQUEST { Check for requests to /retrieve.asp if { [string tolower [HTTP::path]] eq "/retrieve.asp"}{ Redirect the request to /Servicepages/RetrieveDocument.aspx with the guid parameter value set as did HTTP::redirect "/Servicepages/RetrieveDocument.aspx?did=[URI::query "?&[HTTP::query]" &guid]" } }
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