Welcome to WebmasterWorld Guest from 220.127.116.11
Be aware this creates a problem in that non-www requests are redirected to non-www and www requests are redirected to www. This means an old request for the non-canonical hostname invokes a two-step (or more) redirection chain.
It is possible to add extra code such that all requests redirect to www in one step, but this gets messy.
Be aware that your example code redirects various URLs that always end with a trailing slash but your URLs presented as examples do not have a trailing slash.