I applied the following mod_rewrite rule in Apache2 to redirect from non www to www:
mod_rewrite
Apache2
RewriteEngine On RewriteCond %{HTTP_HOST} ^exa
Putting a slash into your pattern should resolve this issue:
RewriteRule ^/(.*)$ http://www.example.com/$1 [R=301,L]