In this tutorial i am going to show you how to redirect example.com to www.example.com. It is very important to redirect your website to example.com towww.example.com.
For example, if a visitor goes to example.com, you may want them to be automatically redirected to www.example.com, or vice versa. I will simply show you how we can do it using .htaccess file.
Just create a .htaccess file and paste this below code in your htaccess file.
.htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
#htaccess #redirect-to #www-to-non-www #non-www-to-www