Website- How to redirect non www to www in htaccess


In this tutorials, we are going to share the trick for redirecting a non-www website to www. Most of the time website owner want to redirect their website and a www website look more professional to a non-www.

To do that we need to create a .htaccess file in your root directory and add the below code.

Please note .htaccess is not a file extension. It’s simply the .htaccess or [dot]htaccess.

.htaccess
RewriteEngine On

RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Similar Posts

About the Author

Atul Rai
I love sharing my experiments and ideas with everyone by writing articles on the latest technological trends. Read all published posts by Atul Rai.