Forum Discussion
dacrud_18985
Nimbostratus
May 20, 2008redirect help
Hi all,
So this is the iRule I'm trying to create:
* redirect anything.domain.com to www.domain.com
* if anything.domain.com/us, first make it www.domain.com/us an...
hoolio
Cirrostratus
May 20, 2008Hi,
If anything.domain.com and www.domain.com resolve to this VIP, you'll get a redirect loop using HTTP::host contains "domain.com". Here is one approach you could take. I'm sure there alternatives as well.
when HTTP_REQUEST {
Check if host isn't www.domain.com
if {not ([string tolower [HTTP::host]] eq "www.domain.com")}{
log local0. "[IP::client_addr]:[TCP::client_port]: redirecting request from [HTTP::host][HTTP::uri] \
to http://www.domain.com[HTTP::uri]"
Redirect to www.domain.com with the original URI appended
HTTP::redirect http://www.domain.com[HTTP::uri]
} else {
Select the pool based on the start of the requested path
switch -glob [HTTP::path] {
"/us*" {
Path started with /us, so use US pool
pool US_pool
log local0. "[IP::client_addr]:[TCP::client_port]: using pool US_pool"
}
"/au*" {
Path started with /au, so use US pool
pool AU_pool
log local0. "[IP::client_addr]:[TCP::client_port]: using pool AU_pool"
}
default {
Didn't match any of the above cases, so take some default action.
pool default_pool
log local0. "[IP::client_addr]:[TCP::client_port]: using default pool"
}
}
}
}
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
