Knowledgebase Home / How to force www or non-www versions of your website using .htaccess rules
// View Comments //

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.


If you have any web hosting questions please feel free to reach out to us. We're happy to help.
Shared Hosting | Reseller Hosting | Managed WordPress Hosting | Fully Managed VPS Hosting

Our Guiding Principles

  • Provide consistent, stable, and reliable web hosting services.
  • Ensure rapid ticket response and quick resolutions to issues.
  • Never saturate or over-provision servers to ensure stability and speed for our customers.
  • Use only high-quality enterprise-class hardware to ensure minimal downtime from hardware failures.
  • Provide clear pricing with no hidden fees or gotchas.
Subscribe to comment notifications
Notify of
guest
0 Comments
Inline Feedbacks
View all comments