21-May-2021 11:57
i have irule with redirect some uri and the rest of them redirect to the Home page. i don't know why it is not go to home page. i appreciate your help.
Thanks
when HTTP_REQUEST {
if { [HTTP::host] equals "www.ABC.com" }
{
switch -glob [HTTP::path]
{
"/Content"
{ HTTP::respond 301 Location "https://www.CDF.com/legacy/Content"
}
"/Programs"
{ HTTP::respond 301 Location "https://www.CDF.com/legacy/Programs"
}
default
{HTTP::respond "https://www.CDF.com"}
}
}
}
21-May-2021
18:17
- last edited on
04-Jun-2023
20:53
by
JimmyPackets
Hi Hien Truong,
Can you add "30x Location" after "HTTP::respond" for default case?
or you can use HTTP::redirect
# 301
default { HTTP::respond 301 Location "https://www.CDF.com" }
# 302
default { HTTP::redirect "https://www.CDF.com" }
24-May-2021 12:58
Hi Enes;
i appreciate for your reply, i tried to change both # 301 or #302 in my irule, when typing www.ABC.com, it redirect to www.CDF.com (that's good) but when i type www.ABC.com/#about for example, it will redirect to www.CDF.com/#about. we want the rest of them go to home page www.CDF.com only (beside of /Content and /Programs). Any input i appreciate it.
Thanks
25-May-2021
01:25
- last edited on
04-Jun-2023
20:53
by
JimmyPackets
Considering your VIP is hosting many applications and this rule should only be applied for www.abc.com HOST. You can try the below iRule
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
switch -glob [string tolower [HTTP::host]] {
"www.abc.com" {
if {$uri starts_with "/content" or $uri starts_with "/programs" } {
HTTP::respond 301 Location "https://www.cdf.com/legacy[HTTP::uri]"
} else {
HTTP::respond 301 Location "https://www.cdf.com"
}
}
default {
return
}
}
}
26-May-2021 14:32
it works, thanks for your support.