You’re first rule had two conditions for getting traffic to a specific pool, whereas your new rule dumps every class-defined request into FS-Prod, so they are not identical functionally..
In any event, you can use the timing on command to know for sure which is more efficient. Check out the wiki for usage.
Yes, the HTTP::redirect command is only valid within a HTTP event.
Another thing: In your iRule, if $::OPS_IP and $::Admin_IP are data groups, then you’ll have to use the matchclass command and not a straight equality. If you just use an equals comparison, then I believe it will only compare against the first item in the data group.
I think it would be simpler to put the whole rule in the HTTP_REQUEST event if you want to send an HTTP redirect. Also, the redirect should be in the else of the if/elseif/else chain so that clients that aren’t in either class will be redirected.
See if this works better for you:
when HTTP_REQUEST {
if { [matchclass [IP::remote_addr] equals $::OPS_IP] } {
pool FS-OPS
} elseif { [matchclass [IP::remote_addr] equals $::ADMIN_IP] } {
pool FS-Prod
} else {
HTTP::redirect "http://myurl/accessdenied.htm"
}
}