cancel
Showing results for 
Search instead for 
Did you mean: 

Redirect Two URLs to Single URL

Korai
Nimbostratus
Nimbostratus

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 https://xyz.com/path2 should be redirected to https://newsite.com/path3/abc

 

what irule should I use to achieve this.

6 REPLIES 6

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
Nimbostratus
Nimbostratus

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
Nimbostratus
Nimbostratus

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 } }

 

Thanks It works

 

Both URLs are directed to single URL and successfully tested