Forum Discussion
iRule Help - Capture URI, Modify, and Redirect
This got shelved and then was resurrected for use. Below is the current form of the iRule. I'm receiving an error in the ltm log.
err tmm[15729]: 01220001:3: TCL error: /Partition/iRule - invalid command name "6"; while executing "[scan $URI {/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]} 1 2 3 4 5 6]";
err tmm[15729]: 01220001:3: TCL error: /Partition/iRule - invalid command name "6"; while executing "[scan $URI {/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]} 7 8 9 10 11 12]";
The rule will execute only when not calling one of the variables. It seems like it is not actually setting the numbers 1-12 as a variable. I'm not sure how to take this further and resolve it. Any help is much appreciated.
when HTTP_REQUEST {
set URI [string tolower [HTTP::uri]]
if { $URI equals "/" or $URI equals ""} {
HTTP::respond 301 Location "https://My.site.org/mysite"
} elseif { $URI contains "find-a-thing1" and $URI contains "thing1detail" } {
[scan $URI {/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]} 1 2 3 4 5 6]
HTTP::respond 301 Location "https://my.site.org/things1/$5"
log local0. "Legacy Find Thing1 value is $5"
} elseif { $URI contains "find-a-thing1"} {
HTTP::respond 301 Location "https://my.site.org/things1"
} elseif { $URI contains "find-a-thing2" and $URI contains "thing2detail"} {
[scan $URI {/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]/%[^/]} 7 8 9 10 11 12]
HTTP::respond 301 Location "https://my.site.org/things2/$11/$12"
log local0. "Legacy Find Thing2 values are $11 and $12"
} elseif { $URI contains "find-a-thing2"} {
HTTP::respond 301 Location "https://my.site.org/things2"
}
}
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