I am trying to change my url when someone visits my site so non-www redirects to www ...http://example.com to http://www.example.com
I have found this code
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*) http://www.example.com/$1 [R=301]
But when i add it to my .htaccess i get a error....is this the wrong code ?? How do i add this to my .htaccess with out getting a error?
My .htaccess
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ / profile.php?username=$1