Match & redirect based on URIs to another site with similar URIs structured
Hi all,
I would like to know if anyone can help provide recommendations on this iRUle where it will only match based on the URIs from the old site, and from there redirect to a new site with similar URIs. The new site will have the exact same URIs, so it would be simple as it is 1 to 1 matching.
The example is below is using a data group, and I have not tested this code yet, but if anyone can suggest a better way to do this, all suggestion appreciated.. The goal here is to make it where it's easy to add/remove and modify, and using the data group string is the best way to do so as the there are only one new site to go to.
Note, i am running 11.5.x code
class my_uri_datagroup {
{
"/uri1/ my.newsite.com"
"/uri2/ my.newsite.com"
"/uri3/ my.newsite.com"
"/uri4/ my.newsite.com"
"/uri5/ my.newsite.com"
"/uri6/ my.newsite.com"
"/uri7/ my.newsite.com"
"/uri8/ my.newsite.com"
"/uri9/ my.newsite.com"
}
}
when HTTP_REQUEST {
set newhost [findclass [string tolower [URI::path [HTTP::uri] 1 1]] my_uri_datagroup " "]
if { [string tolower [HTTP::host]] equals "my.oldsite.com" and $newhost ne "" } {
HTTP::redirect "http://$newhost[HTTP::uri]"
}
}
}
my.oldsite.com/uri1 -> my.newsite.com/uri1
my.oldsite.com/uri2 -> my.newsite.com/uri2
my.oldsite.com/uri3 -> my.newsite.com/uri3
my.oldsite.com/uri4 -> my.newsite.com/uri4
my.oldsite.com/uri5 -> my.newsite.com/uri5
my.oldsite.com/uri6 -> my.newsite.com/uri6
my.oldsite.com/uri7 -> my.newsite.com/uri7
my.oldsite.com/uri8 -> my.newsite.com/uri8
my.oldsite.com/uri9 -> my.newsite.com/uri9