How do I add or remove www from my domain? - Gregg Hosting

The affects of Web Hosts on Your Business Website

Here're ways your choice of web hosting service provider impacts the performance of your business:


check

Website loading speed

check

Uptime and availability

check

Customer support

check

Security

check

Server location

How do I add or remove www from my domain?

How do I add or remove www from my domain?

add or remove

Overview

You have the choice of adding the ‘www’ subdomain in front of your domain, leaving it off entirely, or allowing both options when you fully host it. Consider the following scenario:

www.example.com
example.com
While some people prefer not to include “www” in their website URL, others insist on it. In any case, having a single canonical name by which your site may be reached can be handy at times. This post will show you how to do both.

Domains hosted on GreggPress are not covered by this article. To force a redirect on GreggPress sites, you’ll need to change your.htaccess file.

Adding or removing “www” in the panel

A 301 redirect is created using this option.

Go to the Manage Domains section.
Under the Web Hosting column, click the Edit button to the right of your domain.
The page ‘Manage Domain’ appears:

Next to ‘Do you want the www in your URL?’ choose one of the three options:
Allow it to be: Both www.example.com and example.com are valid domain names.
Add WWW: Requires all requests to include the www (i.e., all requests to example.com go to www.example.com).
Remove WWW: Requires all queries to include the word www (i.e., all requests to www.example.com go to example.com).
To save your changes, scroll down and click the Change settings button.
Your site will redirect to the ‘www’ version of the URL in around 10 minutes.

Adding or removing “www” using a .htaccess file

If you don’t want to use the panel, you can still use an.htaccess file to add or remove ‘www.’

This requires you to create and edit a file on your web server. For more information, see the following articles:

Overview of the.htaccess file
Using FTP to create and edit a file
Using SSH to create and edit a file
Overview of SSH
Using an.htaccess file to remove “www”
Add the following mod rewrite rule to your.htaccess file to remove the www from the beginning of your domain. Create that file in a text editor and upload it to your root directory if you don’t already have it:

percent HTTP HOST www.(.+) RewriteEngine on RewriteCond

$ [NC] RewriteRule (.*) $ [NC] RewriteRule (.*) $ [NC] RewriteRule (.*

percent 1/$1 [R=301,L] $ http:// percent 1/$1 [R=301,L]
Using an.htaccess file to force the ‘www’ subdomain
You can use the following mod rewrite rule in your.htaccess file to compel the use of “www” when viewers are reading your site:

On RewriteCond percent HTTP HOST! RewriteEngine

www\.example\.com

[NC] $
(.*) RewriteRule
The URL will now change to www.example.com whenever someone types in example.com.

When add or remove “www” breaks WordPress

WordPress is unique in that the URL must either include or exclude www from the domain name. If your database requires www but your panel does not (or vice versa), you may receive a redirect loop error like this:

There are two options for dealing with this.

Option#1
Set the option to Leave it alone in the drop-down menu above.

Choice #2 Double-check that the option in your GreggHost panel corresponds to the WordPress configuration you choose. For information on how to adjust all URLs in your WordPress site, see the Change WordPress Site URL article.

Additional information

While most domains set up their main web server to respond to both forms, few use this type of redirection from one to the other. In the end, it doesn’t matter what name is used to access a site as long as the material supplied is the same.
Search Engine Optimization is one factor to consider when considering whether to redirect example.com to www.example.com (or vice versa) (SEO). Many search engines penalize websites that “mirror” their content (having the same content at many URLs) across multiple domains and/or subdomains. Although spiders are unlikely to blacklist a “www” mirror, it’s wise to be careful and choose one and redirect the other to it.

Using www with Cloudflare

You must force the URL to redirect to the www version if your site is utilizing the Basic Cloudflare plan in the panel. For more information, see the following article:

Subscriptions to Cloudflare