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"
}
}
- Steve_M__153836Dec 04, 2015NimbostratusForgot to mention that error in the LTM log corresponds with RST of the connection. Also it happens if the variable attempting to be being called is one other than 6. Further troubleshooting indicates that the the error isn't referencing the varialbe, but the position among each section of the URI that is being scanned via the scan command. I'm at a loss on how to get more diagnostic info out of this to help find a resolution.
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