Redirect non-www to www using .htaccess

The code in this article added at the begining of the .htaccess file, will redirect non-www urls to corespondent www, as expected.

# BEGIN nowww
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END nowwwCode language: PHP (php)