This page looks best with JavaScript enabled

How to redirect non-www URLs to www?

 ·  ☕ 1 min read  ·  👽 john hashim

To redirect your website from non-www to www, add the following lines in your website’s .htaccess file:

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

Replace domain.com with your actual domain name.

Share on

john hashim
WRITTEN BY
john hashim
Web Developer