Forwarding from non-www to www domain using URL rewrite rules in Apache

Posted by in Code Snippets, Technology

Problem Description:
With the installation of WordPress multisite network in my site, entering the URL took me to the signup page whereas entering took me to the homepage as it should! I wanted to redirect to and to

I put the following block of codes right under the ruleĀ RewriteEngine On in .htaccess file and everything is a smooth sailing here onwards!

RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

PS: 301 is a search engine friendly HTTP redirect.