Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Irule to redirect all URI from old site to a new site with matching URI

Hi all

How can I write an iRule that will redirect all URI from one site to a new site and match the URI

https://www.universitysite.com/news-archives/ or anything under that to https://new-site.com/news-archives/ ?

thanks

Chung

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

You could also do it this way:

when HTTP_REQUEST {
     if { [HTTP::host] equals "www.universitysite.com" } {
        HTTP::respond 301 Location "new-site.com[HTTP::uri]"
    }
}

Just modify the if statement to cover the scenarios you want to perform the redirect on.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

There are lots of redirect examples on DevCentral, but here is a simple iRule that should work.

when HTTP_REQUEST {
    if { [HTTP::host] equals "www.universitysite.com" } {
        HTTP::redirect "https://newsite.com[HTTP::uri]"
    }
}

This can also be done more efficiently with a Local Traffic Policy than with an iRule. The condition would look something like this:

HTTP Host full string is any of www.universitysite.com at request time

The action would look something like this:

Redirect to location tcl:https://newsite.com[HTTP::uri]

See this answer for more details.

0
Comments on this Answer
Comment made 3 months ago by chungyu 250

Hi

thanks a lot - I ended up with something like this - but I did not know about using the Local Traffic Policy. It looks interesting, I will keep it in mind.

Thanks again.

when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/archives/" || [string tolower [HTTP::uri]] starts_with "/archives} { HTTP::redirect "https://school-archives.universityca[HTTP::uri]" } }

0