How to Redirect Non-WWW to WWW And Why It Matters To SEO

Before digging into how to redirect non-www. to www. or vice versa of a domain, we want to briefly discuss the structure of a domain.

A domain name structure is broken into three sections:

  • Top-level domain: Top-level domain, also known as TLD, refers to the .ca, .com, etc. of the domain structure. For example, .ca is the TLD of
  • Domain name: The domain name is the root domain of the domain structure. rwdigital is the domain name of
  • Subdomain: Subdomain is the prefix before the domain name. For example, www. is the subdomain of
Htaccess Redirect

It’s important to redirect www. to non-www. or vice versa so there’s one central domain structure of your website. If you have the instances of two URLs and neither one redirects to one location, then you’d encounter duplicate content issues. Google would see two unique websites with the exact same content and the search engine would think that you’ve created multiple websites using the same content and try to rank multiple ranks on search results. Google would then penalize you by de-indexing your websites or dropping your ranking. Neither outcome is desirable.

To prevent encountering such issues, you can redirect www. to non-www or vice versa by writing the following codes in your .htaccess file.

Redirect to non-www.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Redirect to www.

RewriteEngine on
RewriteCoud %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*){REQUEST_URI} [L,R=301]

Please remember to change to your website URL.

If you have any questions about setting up www. to non-www. or vice versa or SEO, please feel free to get in touch via form below.

Get In Touch

Contact Us

We are here to help you 7 days a week. If you have any questions or want to say ‘hi’, please feel free to get in touch!