Forum Discussion
iRule to redirect if querystring matches list
Hi I have a request to redirect users to a different URL for matching parameters. For example;
Current URL: https://xxx.domain.com/Foo/Bar?aa=NNNNNNN
New URL: https://yyy.domain.com/?aa=NNNNNN
Where NNNNNN is a unique identifier.
I would ideally like to hold a list of these NNNN's in a Data Group and redirect sessions if NNNNNNN matches a item in a Data Group.
Any pointers would be much appreciated.
- Leonardo_Souza
Cirrocumulus
You can use a URI::query to get a parameter value:
https://devcentral.f5.com/wiki/iRules.uri__query.ashx
Use the class command to work with a datagroup:
https://devcentral.f5.com/wiki/irules.class.ashx
Both links have iRules examples at the end of the page, so you just need to take the code part you need and create your iRule.
- Samir_Jha_52506
Noctilucent
Please validate below iRule. Hope it will work.
class redirectURIs { NNN AAA BBB } when HTTP_REQUEST { if { [matchclass [URI::query [HTTP::uri] aa] equals redirectURIs] } { HTTP::respond 302 Location "https://yyy.domain.com/?aa=[URI::query [HTTP::uri] aa]" } }
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