Forum Discussion
URI Rewrite based on cookie value
Hey Devcentral,
I'm trying to come up with the best way to modify a URI based on a cookie value. I have control over the cookie value and would prefer to just do a simple string replace and replace part of the uri with whatever the value of the cookie is. I have some semi-psuedo code below that illustrates this a bit better.
The value of the cookie would be "-A2" or "A2" or something similar we could do an easy string replace on, this way if we decide to add A3 and A4 we don't need to update the Irule, just add the extra environments themselves.
What my question boils down to is: Is there a way to just set the cookie value to a variable and then reuse that in the irule script
http://abc.com to http://abc-a2.com
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "abc.com" } { HTTP::uri [string map -nocase {"abc.com" "abc-[cookievalue].com"} [HTTP::uri]] } }
Any help or guidance would be greatly appreciated.
Thanks, Beatty754
1 Reply
- Vijay_E
Cirrus
I am not sure if it will work but I think you are looking for something like this:
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "abc.com" } { HTTP::uri [string map -nocase {"abc.com" "abc-[HTTP::cookie value cookie-name].com"} [HTTP::uri]] } }
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