Tomeq_93315
May 07, 2019Nimbostratus
redirection with 301 code plus "www" append doesn't work, why?
Hi,
I tried to implement iRule to redirect traffic from http tcp/80 port VIP to https with code 301 and additional appending "www" clause to url when there is none present. Also, I would like to do same when https:// no www url is being invoked. But it seems that this method fails whenever I will add "www" clause to HTTP::respond term. What am I doing wrong? This 13.0.0 sofware virtual appliance if this matters.
rule looks like this:
when HTTP_REQUEST {
if { not ([string tolower [HTTP::host]] starts_with "www.") and [string match {[a-zA-Z]} [HTTP::host]] }
{
HTTP::respond 301 noserver Location "https://www.[getfield [HTTP::host] ":" 1][HTTP::uri]"
} else {
HTTP::respond 301 noserver Location "https://[HTTP::host][HTTP::uri]"
}
}
Any ideas how to solve this? I'm a bit lost.