Welcome to WebmasterWorld Guest from 188.8.131.52
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.