Forum Discussion
smiley_dba_1116
Nimbostratus
Jun 28, 2010HTTP header redirect
V.10.2
Having a issue when trying to do a redirect. When a client types in www.xxx.com, we want the load balancer to look at the header, and auto redirect to www.yyy.com. Currently, I tried to use the following:
when HTTP_REQUEST {
if { ([HTTP::host] != "www.xxx.com") } {
HTTP::redirect "http://www.yyy.com"
}
}
I does not redirect at all. it just sits there. Any help is great appreciated.
- Chris_Miller
Altostratus
Posted By smiley_dba on 06/28/2010 09:18 AM V.10.2when HTTP_REQUEST { if { ([HTTP::host] eq "www.xxx.com") } { HTTP::redirect "http://www.yyy.com" } }
- hoolio
Cirrostratus
Or maybe you could change the rule to check if the host isn't www.yyy.com redirect to www.yyy.com? Either way, adding debug logging is a good way to figure out what code is executing:when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]" if { ([HTTP::host] != "www.yyy.com") } { log local0. "[IP::client_addr]:[TCP::client_port]: Matched host check, redirecting." HTTP::redirect "http://www.yyy.com" } }
- smiley_dba_1116
Nimbostratus
Received an error: - smiley_dba_1116
Nimbostratus
Tried the - Michael_Yates
Nimbostratus
The Rule that is giving you an Error doesn't have your previous "if not" matching requirement.when HTTP_REQUEST { if { !([HTTP::host] equals "www.xxx.com") } { HTTP::redirect "http://www.yyy.com" HTTP::respond 301 Location "http://www.yyy.com" } }
- hoolio
Cirrostratus
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