Forum Discussion
Raj_74912
Nimbostratus
Jun 01, 2010Greedy iRule. Need not so greedy one.
Guys and Gals,
I currently have a problem that I am trying to solve. I have a website called www.abc.com and want all requests only going to www.abc.com// to go to a different pool than normal traffic.
Following is what I wrote but the problem is traffic going to www.abc.com//1234/page1.html or www.abc.com//page1.html all goes to redirect pool. I need only
www.abc.com") and ([HTTP::uri] matches_regex "^\/.*?\/")) and ( not ([HTTP::cookie exists $::cknameexist]))} {
set ::proxypool 1
pool proxy.abc.com-80
}
}
when HTTP_RESPONSE {
if {$::proxypool == 1} {
HTTP::cookie insert name "Proxy" value "Enabled" domain "abc.com" path "/"
}
if {($::proxypool == 0)} {
HTTP::cookie remove $::ckname
}
}
Thanks in advance for all your expert help.
Raj
4 Replies
- hoolio
Cirrostratus
Hi Raj,
First, I'd suggest changing all of your variables to local ones and removing the RULE_INIT event. Any variable set in RULE_INIT defaults to be a global. Global variables will be shared across all connections for all virtual servers. Then I'd replace the matches_regex command with a string function. Are you trying to literally matching only a URI of //? If so you can check for it using [HTTP::uri] eq "//". If that's not what you're after, can you clarify?
Thanks, Aaron - Raj_74912
Nimbostratus
I can change the variables to local. I am trying to only match URI that starts and end with with / - Raj_74912
Nimbostratus
oh wow. I just noticed the form edited my text folks.
So to clarify I am only trying to match on URI that start and end with /something_here/. What is happening currently is that the iRule is also matching on things like /something_here/1234/page1.html or like /something_here/page1.html. - hoolio
Cirrostratus
You could do this with two string functions instead of a regex for better effciency:
[HTTP::uri] starts_with "/" && [HTTP::uri] ends_with "/"
For information only, you could use a regex like this to match / or /anything/:
^(?:/.*/|/)$
tests:
% regexp {^(?:/.*/|/)$} /test/123/
1
% regexp {^(?:/.*/|/)$} /
1
% regexp {^(?:/.*/|/)$} /test/123
0
%
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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