I have a virtual server on port 80 redirecting traffic to another vs on 443 via http 301 responses in an iRule:
if { [HTTP::host] equals "www.myexample.com" or [HTTP::host] equals "myexample.com"} {
HTTP::respond 301 Location "https://myexample.com[HTTP::uri]" }
A wildcard certificate is in use for the 443 vs, “*.myexample.com”.
I’ve been asked to move a site to the same server, and to do the same thing with a number of subsites/URIs. Not being very familiar with iRules, I have added this to the applied rule:
when HTTP_REQUEST {
if { [HTTP::host] equals "www.myexample.com" or [HTTP::host] equals "myexample.com"} {
HTTP::respond 301 Location "https://myexample.com[HTTP::uri]" }
elseif { [HTTP::host] equals "blog.myexample.com"} {
HTTP::respond 301 Location "https://myexample.com[HTTP::uri]" }
elseif { [HTTP::host] equals "blog.myexample.com" and [HTTP::uri] equals "/ddc"}
HTTP::respond 301 Location "https://uk.myexample.com" }
elseif { [HTTP::host] equals "blog.myexample.com" and [HTTP::uri] equals "/tree-tales"}
HTTP::respond 301 Location "https://uk.myexample.com" }
elseif { [HTTP::host] equals "blog.myexample.com" and [HTTP::uri] equals "/made-here"}
HTTP::respond 301 Location "https://uk.myexample.com" }
elseif { [HTTP::host] equals "blog.myexample.com" and [HTTP::uri] equals "/con21-reaction"}
HTTP::respond 301 Location "https://uk.myexample.com" }
elseif { [HTTP::host] equals "blog.myexample.com" and [HTTP::uri] equals "/btp"} {
HTTP::respond 301 Location "https://uk.myexample.com/projects/uk/b-2-p/" }
elseif { [HTTP::host] equals "blog.myexample.com" and [HTTP::uri] equals "/bas"} {
HTTP::respond 301 Location "https://uk.myexample.com/projects/uk/b-a-s" }
elseif { [HTTP::host] equals "blog.myexample.com" and [HTTP::uri] equals "/tenbelt"} {
HTTP::respond 301 Location "https://myexample.com/belt" }
elseif { [HTTP::host] equals "blog.myexample.com" and [HTTP::uri] equals "/urban"} {
HTTP::respond 301 Location "https://myexample.com/U_L_C" }
elseif { [HTTP::host] equals "blog.myexample.com" and [HTTP::uri] equals "/bhfl"} {
HTTP::respond 301 Location "https://uk.myexample.com/projects/uk/b_h_f_l" }
}
}
With this in place, I get a correct redirect from:
blog.myexample.com/con21-reaction
but
blog.myexample.com/btp returns myexample.com/btp
blog.myexample.com/bas returns myexample.com/bas
As far as I can tell they are the same as the others and the redirect location itself each responds correctly.
Any pointers on why these couple of redirects might be breaking?
Many thanks
Kev