Forum Discussion
iRule URL redirect help required.
We would like this example URL to be redirected from:
http://link.ecm.tn.exp/81213457&Open
to be this:
http://link.ecm.tn.exp/Livelink/livelink.exe?func=LL.login&username=Anonymous&password=&NextURL=%2FLivelink%2Flivelink%2Eexe%3Ffunc%3Dll%26objId%3D81213457%26objAction%3DOpen
the yellow item is the document number
the pink item is the action, either be open or download for the vast majority of cases.
So whatever the yellow and pink values are in the first uri will have to be mirrored in the redirected url.
Any help would be greatly appreciated.
David
6 Replies
- Brian_69413
Nimbostratus
This is pretty straight forward, but you will have to do some string manipulation. Basically you will need these steps:
1) Strip out the two parts of the incoming URL into variables
2) Build a new variable with the new URL and the other variables
3) Redirect to that new variable
Does that make sense? - David_Stephenso
Nimbostratus
Hi Brian, thanks for the reply. I had sort of worked that out logically but I have no idea of the code to use. I have had no training in creating irules but have just manipulated exsisting rules on our loadbalancers.Any code example that would fit my requirements would be a massive help
Thanks, David - Colin_Walker_12Historic F5 AccountThis is definitely possible, but I'd need to know a little bit more information first.
1) Is the URI of the origin going to be the same, always (I.E. always starts with the document number&action)?
2) What is the terminator (if any) after the action on the origin URI? (is it just those two items then the end of the URI every time? If not, what comes after it?)
3) Will the redirect URI be the same every time, other than the object number and action?
Thanks!
Colin - David_Stephenso
Nimbostratus
Hi Colin,
1) Is the URI of the origin going to be the same, always (I.E. always starts with the document number&action)?
Yes
2) What is the terminator (if any) after the action on the origin URI? (is it just those two items then the end of the URI every time? If not, what comes after it?)
There would not be anything else after the tow variables, the url is an example format and can be changed to make the irule easier if required, all we want to do is pass 2 variables in a url and then redirect it to the longer url,
3) Will the redirect URI be the same every time, other than the object number and action?
Yes
Many thanks! - Colin_Walker_12Historic F5 AccountCool, then this shouldn't be horrible. You'd need something like:
when HTTP_REQUEST { if {[scan [HTTP::uri] "/%d&%s" dnum action] == 2} { HTTP::redirect "http://link.ecm.tn.exp/Livelink/livelink.exe?func=LL.login&username=Anonymous&password=&NextURL=%2FLivelink%2Flivelink%2Eexe%3Ffunc%3Dll%26objId%3D$dnum%26objAction%3D$action" } else { log local0. "URI: [HTTP::uri] did not match" } }
Keep in mind that this will match any URI with /& format, and if you want to do some more specific checking you could analyze the dnum and action variables once they were set by the scan command to see if the action matches an appropriate action or something to that effect, but it sounds like the URI is something you're controlling anyway, so I wasn't horribly worried about that.
Let me know if that works, and/or if you have any further questions.
Colin - David_Stephenso
Nimbostratus
Colin,
Thank you so much. That worked perfectly. The team have tested and have confirmed that it works exactly as they wanted it to.
Many thanks again.
David
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