Hi Javier,
Here is an iRule you can use to send a 301 redirect to the same host and URI with www. prepended:
when HTTP_REQUEST {
Check if Host header value has at least one alpha character and doesn't already start with www.
if {[string match {[a-zA-Z]} [HTTP::host]] and not ([string tolower [HTTP::host]] starts_with "www."}{
Send a 301 redirect to the same host and URI with www. prepended
HTTP::respond 301 Location "http://www.[HTTP::host][HTTP::uri]"
}
}
If you are using this on an HTTPS VS and you don't have a cert valid for both example.com and
www.example.com, the client will get a mismatched cert warning before the iRule triggers.
Aaron