1. square brackets, e.g. [
www.hallmark.com||hallmark.com], evaluates of content as a command.
iRules Optimization 101 - 04 - Delimiters: Braces, Brackets, Quotes and more by Deb
https://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/120/iRules-Optimization-101--04--Delimiters-Braces-Brackets-Quotes-and-more.aspx
2. HTTP::redirect uses 302. If you want 301, you have to use HTTP::respond instead.
HTTP::respond wiki
https://devcentral.f5.com/wiki/irules.HTTP__respond.ashx
3. since local variable will be gone after closing connection, unset may be omitted.
can you try this irule?
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
set host [string tolower [HTTP::host]]
if { not ($host equals "www.hallmark.com" or $host equals "hallmark.com") } {
set vanityuri [class match -value [string tolower [HTTP::host]] equals vanityurls]
if {$vanityuri ne ""} {
HTTP::respond 301 Location "$vanityuri"
} else {
HTTP::respond 301 Location "http://www.hallmark.com/"
}
}
set queryyuri [class match -value [string tolower [HTTP::path]] equals queryurls]
if {$queryuri ne ""} {
HTTP::respond 301 Location "$queryuri[HTTP::query]"
}
set exacturi [class match -value [string tolower [HTTP::path]] equals exacturls]
if {$exacturi ne ""} {
HTTP::respond 301 Location "$exacturi"
}
set starturi [class match -value [string tolower [HTTP::path]] starts_with startturls]
if {$starturi ne ""} {
HTTP::respond 301 Location "$starturi"
}
set containturi [class match -value [string tolower [HTTP::path]] contains containurls]
if {$containuri ne ""} {
HTTP::respond 301 Location "$containuri"
}
}
}