Korai
March 1, 2021, 3:21am
1
Hi,
I have a requirement to redirect traffic for two URLs to a single URL by using irule.
Suppose traffic for https://abc.com/path1 and for .xyz Domain Names | Join Generation XYZ should be redirected to https://newsite.com/path3/abc
what irule should I use to achieve this.
Something like this should do,
if {(([HTTP::host] eq "abc.com") && ([string tolower [HTTP::uri]] starts_with "/path1")) || (([HTTP::host] eq "xyz.com") && ([string tolower [HTTP::uri]] starts_with "/path2")) } {
HTTP::redirect https://newsite.com/path3/abc
}
Korai
March 1, 2021, 7:35pm
3
Thanks,
Can we make this more simple like because abc.com and xyz.com is same means this part of URL is similar so lets consider this as abc.com for both sites but paths are different and should be redirected to same newsite.com .
Hello,
You can modify above iRule as given below.
if {(([HTTP::host] eq "abc.com") && (([string tolower [HTTP::uri]] starts_with "/path1") || ([string tolower [HTTP::uri]] starts_with "/path2"))) } {
HTTP::redirect https://newsite.com/path3/abc
}
Hope it helps!
Korai
March 3, 2021, 11:18pm
5
getting errors, looks format is not right as unable to save it
Hi, use below iRule.
when HTTP_REQUEST {
if {(([HTTP::host] eq "abc.com") && (([string tolower [HTTP::uri]] starts_with "/path1") || ([string tolower [HTTP::uri]] starts_with "/path2"))) }
{
HTTP::redirect https://newsite.com/path3/abc
}
}
Korai
March 4, 2021, 7:05pm
7
Thanks It works
Both URLs are directed to single URL and successfully tested