The rule logic looks correct. Can you add a few log statements to see what's happening? I think something like this should work:
log "New request for " + http_host
if (http_host contains one of ValidDomains){
log "Request matched class ValidDomains"
log "substr: " + substr(http_uri, 1, '?')
if (substr(http_uri, 1, '?') contains one of SecurePages) {
log "redirecting to https://" + http_host + "/" + http_uri
redirect to "https://%h/%u"
}
else {
log "Client requested non-secure page, sending to pool"
use pool mywebfarm
}
}
else {
log "Client requested invalid host. Redirecting to: http://www.mydomain.com/" + http_uri"
redirect to "http://www.mydomain.com/%u"
}
Aaron