Redirect Non-WWW URLs to WWW with .htaccess
The most common approach is using Apache’s mod_rewrite module. Add this to your .htaccess file in your document root: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301] </IfModule> This uses a 301 permanent redirect, which tells browsers and search engines that the www version is canonical. The conditions…
