Forum Discussion
Benjamin_9120
Nimbostratus
May 30, 2010about regular expressions
Customer will access follow uri:
http://www.test.com/server1
http://www.test.com/server2
......
http://www.test.com/serverN
I want redirect to relate resource base on server1/server2/.../serverN, how can I write this irules?
such as http://www.poc.com/server1 or pool pool_server1.
- The_Bhattman
Nimbostratus
Hi Benjamin,when HTTP_REQUEST { set poolname [HTTP::uri] if { ([HTTP::host] eq "www.test.com") and ([HTTP::uri starts_with "/server" } { pool pool_$poolname } }
- hoolio
Cirrostratus
Hey CB,when HTTP_REQUEST { Check if Host is www.test.com and URI starts with /server if { ([HTTP::host] eq "www.test.com") and ([HTTP::uri] matches_glob {/server[0-9]*}) } { log local0. "[IP::client_addr]:[TCP::client_port]: Parsed [string range [HTTP::uri] 1 7] from [HTTP::uri]" Select the pool, taking just server from the URI pool pool_[string range [HTTP::uri] 1 7] } }
when HTTP_REQUEST { Check if Host is www.test.com and URI starts with /server if { ([HTTP::host] eq "www.test.com") and ([string match {/server[0-9]*} [HTTP::uri]]) } { log local0. "[IP::client_addr]:[TCP::client_port]: Parsed [string range [HTTP::uri] 1 7] from [HTTP::uri]" Select the pool, taking just server from the URI pool pool_[string range [HTTP::uri] 1 7] } }
- The_Bhattman
Nimbostratus
You are right....That is what happens when you have sleep deprivation. - Benjamin_9120
Nimbostratus
Thanks for your help! I will try it. - Benjamin_9120
Nimbostratus
I try this irules, but I cannot use "string matches" in v9.x, why? - hoolio
Cirrostratus
Sorry, that was a typo. It should be string match not string_match. Can you try the fixed version above?
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