How to force www or non-www versions of your website using .htaccess rules

To force your website to use either “www” or “non-www” versions, simply use the code below in your .htaccess file in the public_html root OR the location of your websites main files. You may need to create the .htaccess file (AKA dot htaccess)

To force www:

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

To force non-www:

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

Note: If you have a CMS such as WordPress or Joomla, you will need to ensure your website settings from your dashboard reflects the above rules that you use.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Domain Transfers and Status Information

In this KB article we will cover information relating to domain transfers. There are a few...

Transfer already initiated for this domain

The domain transfer status code indicates that a transfer has already been initiated for the...

Domain contacts did not approve transfer of domain

  When a domain transfer is initiated, in most cases and email will be sent to the email address...

Domain is locked at current registrar, or is not yet 60 days old

Domains have a feature called “Registrar Lock” which prevents a domain from being transferred to...

Domain contacts did not respond to verification email

When a domain transfer is submitted, an approval email is sent to the email address listed on the...

Powered by WHMCompleteSolution