cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Not Redirecting from non www to www through .htaccess

Trying to redirect my one of the domain to www from non www. Already try to update .htacess rewrite code but its not working.

 

Default .htaccess code:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

New Code which i have updated:

RewriteEngine on
rewritecond %{http_host} ^coolexample.com [nc]
rewriterule ^(.*)$ http://www.coolexample.com/$1 [r=301,nc]

so what is the solution and which code i write to redirect my site with www.

 

Thanks in advance