iRule Recipe 1: Single URL Explicit Redirect
Series Introduction
Let's face it: there aren't many people out there who have extensive experience with Tcl. Since iRules is a Tcl dialect, that means that finding a solid iRules solution can be ...
Updated Jun 06, 2023
Version 2.0VernonWells
Employee
Joined August 23, 2012
VernonWells
Mar 05, 2018Employee
Absolutely. In that case, you could use a
switch
or a data-group (using class
). I'd recommend, however, that you look into using a Local Traffic Policy. A policy is easy to set up and doesn't require any iRules.
Anyhow, a
switch
based approach might look something like this:
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"abc.com" -
"def.com" {
switch -glob [HTTP::path] {
"/first/second" -
"/first/second/*" {
HTTP::respond 301 Location "https://aaa.bbb.com/"
}
}
}
}
}
This would redirect any request for abc.com or def.com that has a URI Target path starting with /first/second to ";.