How to redirect a non-WWW web address to a WWW web address

How to redirect a non-WWW web address to a WWW web address

Overview
This article explains how to redirect visitors that specify a non-WWW web address to a WWW web address

Attention: If you do not have experience in working with .htaccess files, contact the Nexcess Support Team for assistance to avoid potential harm to your website. 

Prerequisites

  • An existing, enabled .htaccess file for your domain. For instructions, refer to How to create .htaccess files.
  • A back-up of your .htaccess file. 

Instructions

  1. Open your .htaccess file located in your document root directory, /html.
  2. Copy and paste the code below into the file, but replace <example.com> with your actual domain name without the angled brackets.

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

 

For 24-hour assistance any day of the year, contact our Support Team by email or through the Client Portal.

Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Related Articles RSS Feed
How to enable and disable .htaccess files with SiteWorx
Added on Mon, Aug 5, 2013
How to allow or block hostnames and IP addresses
Added on Wed, Jul 31, 2013
Creating and managing custom error pages
Added on Tue, Jul 30, 2013
How to create and manage Apache handlers
Added on Tue, Aug 6, 2013
How to manage index files
Added on Mon, Aug 5, 2013
What is .htpasswd?
Added on Mon, Nov 10, 2014
How to block IPs with .htaccess
Added on Tue, Aug 6, 2013
How to prevent bandwidth theft or Hotlinking
Added on Mon, Aug 5, 2013
How to create .htaccess files
Added on Fri, Aug 2, 2013
How to create URL redirect rules
Added on Tue, Jul 30, 2013