Joe_Pipitone
Sep 30, 2015Nimbostratus
Redirecting - avoiding redirect loop
We have a site that has many pages indexed by search engines. We want all of those pages redirected back to the root domain, removing the uri and redirecting the client to http://domain.com/home.aspx.
The following iRule always results in an HTTP 400 error. I'm also wondering if we can perform a redirect without resulting in a redirect loop - so the URI always redirects the client back to Home.aspx. The code also needs to strip the www.
Thanks for any help.
when HTTP_REQUEST {
if {([string tolower [HTTP::host]] starts_with "www.")} {
HTTP::redirect "http://[string range [HTTP::host] 4 end][HTTP::uri]"
return
} elseif { [TCP::local_port clientside] == 80 } {
HTTP::uri "home.aspx"
return
}
}