In the example "if { $::uri_rewritten equals 0 } {" uses a global variable which would be in effect across all TCP connections. I'm assuming this should be a local variable so it is specific to the single TCP connection that the iRule is executing on.
Aaron