Forum Discussion
I'm trying to write an irule with multiple not scripts in it
I'm working on a project which requires migrating most of the urls for an application suite to similar, but different hostnames. I started with this irule for one url string, but now, they want to keep some of the urls the way they were and some not, so the irule comparison needs to start at a higher level, but not redirect some specific substrings.
I started with this:
when CLIENT_ACCEPTED {event HTTP_REQUEST enable} when HTTP_REQUEST { set MY_HOST [string tolower [HTTP::host]] set MY_URI [string tolower [HTTP::uri]]
if {$MY_URI starts_with "/abcd/web/abcd.client.web/"} { if {$MY_HOST equals "m3.companyname.com"} { HTTP::redirect http://a1.m3.companyname.com$MY_URI } elseif {$MY_HOST equals "internal.m3.companyname.com"} { HTTP::redirect http://internal.a1.m3.companyname.com$MY_URI } elseif {$MY_HOST equals "internal.m3-dc1.companyname.com"} { HTTP::redirect http://internal.a1.m3-dc1.companyname.com$MY_URI } elseif {$MY_HOST equals "internal.m3-dc2.companyname.com"} { HTTP::redirect http://internal.a1.m3-dc2.companyname.com$MY_URI } elseif {$MY_HOST equals "internal.m3-dc3.companyname.com"} { HTTP::redirect http://internal.a1.m3-dc3.companyname.com$MY_URI } event HTTP_REQUEST disable TCP::close } }
when HTTP_RESPONSE {event HTTP_REQUEST enable}
tried this, get syntax/format errors
when CLIENT_ACCEPTED {event HTTP_REQUEST enable} when HTTP_REQUEST { set MY_HOST [string tolower [HTTP::host]] set MY_URI [string tolower [HTTP::uri]]
if {$MY_URI starts_with "/abcd/"} { if {not ($MY_URI starts_with "/abcd/web/abcdpayment.web/") } elseif {not ($MY_URI starts_with "/abcd/web/abcdpaymentprocessing.web/")} { if {$MY_HOST equals "m3.companyname.com"} { HTTP::redirect http://a1.m3.companyname.com$MY_URI } elseif {$MY_HOST equals "internal.m3.companyname.com"} { HTTP::redirect http://internal.a1.m3.companyname.com$MY_URI } elseif {$MY_HOST equals "internal.m3-dc1.companyname.com"} { HTTP::redirect http://internal.a1.m3-dc1.companyname.com$MY_URI } elseif {$MY_HOST equals "internal.m3-dc2.companyname.com"} { HTTP::redirect http://internal.a1.m3-dc2.companyname.com$MY_URI } elseif {$MY_HOST equals "internal.m3-dc3.companyname.com"} { HTTP::redirect http://internal.a1.m3-dc3.companyname.com$MY_URI } event HTTP_REQUEST disable TCP::close } } }
when HTTP_RESPONSE {event HTTP_REQUEST enable}
could use "or", f5 accepted it as syntactically correct, but this try didn't work, still redirected the "not" uris...
when CLIENT_ACCEPTED {event HTTP_REQUEST enable} when HTTP_REQUEST { set MY_HOST [string tolower [HTTP::host]] set MY_URI [string tolower [HTTP::uri]]
if {$MY_URI starts_with "/abcd/"} { if {not ($MY_URI starts_with "/abcd/web/abcdpayment.web/") or not ($MY_URI starts_with "/abcd/web/abcdpaymentprocessing.web/") } { if {$MY_HOST equals "m3.companyname"} { HTTP::redirect $MY_URI } elseif {$MY_HOST equals "internal.m3.companyname"} { HTTP::redirect $MY_URI } elseif {$MY_HOST equals "internal.m3-dc1.companyname"} { HTTP::redirect $MY_URI } elseif {$MY_HOST equals "internal.m3-dc2.companyname"} { HTTP::redirect $MY_URI } elseif {$MY_HOST equals "internal.m3-dc3.companyname"} { HTTP::redirect $MY_URI } event HTTP_REQUEST disable TCP::close } } } when HTTP_RESPONSE {event HTTP_REQUEST enable}
I thought of using a generic "contains", of "/abcd/web/abcdpayment" but I expect more very specific surgical type requests may be desired in the future.
I think using "or" or some other type of comparison must be the better choice, but I may not be skilled enough to find the answer in the time window required.
I appreciate any help you could offer. (I don't know why the last line in the irule is blown up so large)
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