Forum Discussion
Ben_Conrad_8684
Nimbostratus
Nov 03, 2009iRule Help/HTTP:respond assistance
Hello,
I was wondering if someone could give me a hand with an iRule. I am trying to redirect all test.website.com traffic to test.website2.com EXCEPT traffic going to test.website.com...
hoolio
Cirrostratus
Nov 03, 2009Hi Ben,
I think one issue with your iRule is that you'd redirect any request with a host header value of test.website.com to test.website2.com[HTTP::uri] before checking the URI.
How about something like this? If you want an exact match only on the URI, remove the -glob flag from the switch command and the * at the end of /Three/.
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: New [HTTP::method] request to [HTTP::host][HTTP::uri]"
Check requested host header value
if {[string tolower [HTTP::host]] eq "test.website.com"} {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched Host check. Checking URI now."
Check the requested URI
switch -glob [HTTP::uri] {
"/Three*" {
Requested URI started with /Three
log local0. "[IP::client_addr]:[TCP::client_port]: Matched URI check for /Three. Allowing request to go to pool"
}
default {
HTTP::respond 301 Location "http://test.website2.com[HTTP::uri]"
log local0. "[IP::client_addr]:[TCP::client_port]: No URI match. Redirecting to http://test.website2.com[HTTP::uri]"
}
}
}
}
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