rewrite uri and redirect to https

Folks - I seem to be struggling with getting an irule working which does the following:-

If a client hits http://irule.com I want him to end up at https://www.irule.com

http://irule.com and http://www.irule.com go to the same IP address in DNS.

There are two VS setup for www.irule.com one for port 80 and another for port 443

I have tried a variety of irules but I am not having much success.

Any pointers would be helpful.

Thanks,

JD

can you try something like this?

[root@ve1023:Active] config  b virtual bar list
virtual bar {
   destination 172.28.19.79:80
   ip protocol 6
   rules myrule
   profiles {
      http {}
      tcp {}
   }
}
[root@ve1023:Active] config  b rule myrule list
rule myrule {
   when HTTP_REQUEST {
        if {[string tolower [HTTP::host]] equals "irule.com"}{
                HTTP::redirect "https://www.[HTTP::host][HTTP::uri]"
        }
}
}

[root@ve1023:Active] config  curl -I http://irule.com/
HTTP/1.0 302 Found
Location: https://www.irule.com/
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

Thanks for that, it worked a treat. I was trying to get far too complicated - sometimes the solution is right in front of you!