How to add www in url through .htaccess?

Recently I was working on a project and SEO team requested to add WWW forcefully in project URL. I asked why, they said.
“Must have www in your URL! Google Like it.”
So here is .htaccess snippet to force a url with WWW
When you will type http://phpmind.com it will automatically become http://www.phpmind.com

RewriteEngine on

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

This is how I did in this site. I am telling you one .htaccess secret. You can experience here only.

Share

One thought on “How to add www in url through .htaccess?

Leave a Reply

Your email address will not be published. Required fields are marked *