Forum Discussion
david_quint_204
Nimbostratus
Sep 25, 2008Simple HTTP redirects not working
Guys, I am having some issues with migrating an old iRule from v4.x to v9.45. We have an External IP address 65.170.177.8 (NAT'ed to an internal address ie:VIP) that has DNS entries for multiple URL's that are rarely used but need to be redirected to the new websites. The iRule is also checking to see if the request comes in on port 443 and redirects it to port 80. I know that we can probably clean up some of these things and make the rule more efficient. Can someone look at this iRule and see if they know why that I cannot get any redirects to work.
when HTTP_REQUEST {
if {[TCP::server_port] == 443} {
HTTP::redirect "http://[HTTP::host]/[HTTP::uri]"
} else {
if {[HTTP::host] == "www.newlifepubs.com" or [HTTP::host] == "newlifepubs.com"} {
HTTP::redirect "http://www.campuscrusade.com/nlp"
} elseif {[HTTP::host] == "www.mpd.ccci.org" or [HTTP::host] == "mpd.ccci.org"} {
HTTP::redirect "http://staffweb.ccci.org/mpd/index.aspx"
} elseif {[HTTP::host] == "www.staffweb.org" or [HTTP::host] == "staffweb.org" or [HTTP::host] == "staff.ccci.org"} {
HTTP::redirect "http://staffweb.ccci.org"
} elseif {[HTTP::host] == "myspam.ccci.org"} {
HTTP::redirect "https://spam.frontbridge.com"
} elseif {[HTTP::host] == "cars.ccci.org"} {
HTTP::redirect "http://cds.ccci.org/carschoose.asp"
} elseif {[HTTP::host] == "www.movementseverywhere.org" or [HTTP::host] == "movementseverywhere.org"} {
HTTP::redirect "http://www.ccci.org"
} elseif {[HTTP::host] == "www.movementseverywhere.net" or [HTTP::host] == "movementseverywhere.net"} {
HTTP::redirect "http://www.ccci.org"
} elseif {[HTTP::host] == "www.movementseverywhere.com" or [HTTP::host] == "movementseverywhere.com"} {
HTTP::redirect "http://www.ccci.org"
} else {
discard
}
}
}
- Nicolas_Menant
Employee
Hi, - david_quint_204
Nimbostratus
Thanks, I removed the https redirect to http and we still cannot get the url's to redirect to the new url's in the rule. - david_quint_204
Nimbostratus
I forgot to add that there is no Pool assigned to the Virtual Server that these old URL's are in. All of the URL's are hosted at different locations throughtout the world. We are just trying to redirect traffic from an old URL to a new URL. - hoolio
Cirrostratus
Do all of the domains you're redirecting to resolve to the VIP which this rule is running on? From your last post, it sounds like they don't. But if they do, you'll get constant redirect loops unless you check the host and the URI. Perhaps you want to add a check to see if the URI is not / and then redirect for the switch cases where you're redirecting to /.when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New HTTP request to [HTTP::host][HTTP::uri]" switch -glob [string tolower [HTTP::host]] { "*newlifepubs.com" { log local0. "[IP::client_addr]:[TCP::client_port]: Matched 1" HTTP::redirect "http://www.example.com/nlp" } "*mpd.example.org" { log local0. "[IP::client_addr]:[TCP::client_port]: Matched 2" HTTP::redirect "http://staffweb.example.org/mpd/index.aspx" } "*staffweb.org" { log local0. "[IP::client_addr]:[TCP::client_port]: Matched 3" HTTP::redirect "http://staffweb.example.org/" } "staff.example.org" { HTTP::redirect "http://staffweb.example.org/" } "myspam.example.org" { HTTP::redirect "https://spam.example.com/" } "cars.example.org" { HTTP::redirect "http://cds.example.org/carschoose.asp" } "*movementseverywhere.example.org" - "*movementseverywhere.example.net" - "*movementseverywhere.example.com" { HTTP::redirect "http://www.example.org/" } default { log local0. "[IP::client_addr]:[TCP::client_port]: No match" discard } } }
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