Forum Discussion
redirect site using irule
Hi Expert,
We have one requirement from out client but I am not sure whether it is even possible or not. looking for your help on this.
Sample requirement :
https://abc.com/sites/Portal/support/Pages/TechnologySupport.aspx?reqtype=GeneralTech&rt=myPC&sd=aaa&dd=xxx rediect to https://xyz.com/generaltechnical?reqtype=GeneralTech&rt=myPC&sd=aaa&dd=xxx
Text in bold is dynamic portion, they want to add it in redirect url accordingly. I know we can append whole URI portion in redirect site but not sure about portion of it.
Thanks
2 Replies
- DevBabu
Cirrus
You can use HTTP::query to get the portion after "?" and append it to the new redirect URI. https://devcentral.f5.com/wiki/irules.http__query.ashx
Example: when HTTP_REQUEST { HTTP::redirect "https://xyz.com/generaltechnical?[HTTP::query]" } - VernonWells
Employee
Can do it this way (not tested, but should work):
when HTTP_REQUEST { set sd [findstr [HTTP::query] "sd=" 0 "&"] set dd [findstr [HTTP::query] "dd=" 0 "&"] if { $sd ne "" && $dd ne "" } { HTTP::redirect "https://xyz.com/generaltechnical?reqtype=GeneralTech&rt=myPC&$sd&$dd" } }Notice that I don't constrain this conditional; that is, I assume you want to redirect any URI that has sd and dd query parameters. If you want to limit it further, that is simple: just add an
conditional around the entire block that checks for what you need (e.g., HTTP host header, uri-path).if
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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