For years I've been using the following to successfully redirect non WWW urls.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
However, having just installed Wordpress in a subdirectory, I find that it continually redirects from WWW, to non WWW, and eventually times out. No other script does this and I'm wondering if anyone has any experience of this issue with WordPress and if there is an alternate way to deal with this?
I've also tried
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]