Forum Discussion
Ian_Amos_37833
Nimbostratus
Apr 27, 2007Using [HTTP::hostname] & [HTTP::uri]..
Afternoon all,
there is probably a really easy solution for this, but i've not had any F5 training, and have run out of ideas..
To try and explain the situation;
there is a website www.example.com
there is also a UAT copy of the site uat.example.com
there is static content ..com/static/
and databases etc ..com/data/
each of the above are in their own Pools, but are represented by the same Public IP and virtual server.
So far I have an iRule to say
when HTTP_REQUEST {
if { ([HTTP::host] starts_with "uat") } {
HTTP::respond 200 content "<...test...>"
}
}
which works when I go to uat.example.com
How can I incorporate an "AND" statement in the iRule? i.e if HTTP::host starts_with "uat" AND HTTP::uri starts_with "/static/" etc.
I've tried using & but that doesn't work.. what am I doing wrong??
Thanks in advance for your help!
5 Replies
- hoolio
Cirrostratus
"&" is for bitwise operations. You can use "&&" for logical ANDing. Or you can just use "and"!if {[HTTP::host] starts_with "uat" && [HTTP::uri] starts_with "/static/"}{
if {[HTTP::host] starts_with "uat" and [HTTP::uri] starts_with "/static/"}{
- Ian_Amos_37833
Nimbostratus
Thanks for the help! i'm sure I tried 'and' but think I had ()'s around each arguement, which it doesn't like.. - hoolio
Cirrostratus
The format you have posted should work. I tested the following and both the if and elseif actions worked:when HTTP_REQUEST { if {[HTTP::host] starts_with "if" && [HTTP::uri] starts_with "/if"}{ HTTP::respond 200 content "matched if" } elseif { [HTTP::host] starts_with "elseif" && [HTTP::uri] starts_with "/elseif"}{ HTTP::respond 200 content "matched elseif" } }
- Ian_Amos_37833
Nimbostratus
Posted By hoolio on 04/30/2007 2:41 AM
TCL error: Rule UAT-test HTTP_REQUEST - Operation not supported. Multiple redirect/respond invocations not allowed line 2 invoked from within HTTP::respond 200 content htmlheadtitleUAT test1/title/headbodydiv align=centertable border=0 width=60 id=table1trtdauat /...
- hoolio
Cirrostratus
I didn't get any errors. I think the issue might be escaping for your response content. If you change the response content to "test", do you still get the TCL error? If not, you'll need to escape the metacharacters "[", "]" and quotes, in the HTML code of your response with backslashes (\).
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