Forum Discussion
Redirect Two URLs to Single URL
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.
- jaikumar_f5
Noctilucent
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
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
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
Nimbostratus
Thanks It works
Both URLs are directed to single URL and successfully tested
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com