Removing the "www" from your domain

From DreamHost
Jump to: navigation, search

Overview

You have the option when adding a domain name to add or remove the www subdomain in front of it. This article details how to remove this www subdomain.

Removing "www" when a domain is hosted at DreamHost

  1. Navigate to the (Panel > ‘Domains’ > ‘Manage Domains’) page.
  2. Click the Edit button to the right of your domain under the ‘Web Hosting’ column.
    The ‘Manage Domain’ page opens:
    01 Add a domain.png
  3. Select one of the three options next to ‘Do you want the www in your URL?’:
    • Leave it alone: Both www.example.com and example.com will work.
    • Add WWW: Forces all requests to add www (i.e., all requests to example.com will go to www.example.com).
    • Remove WWW: Forces all requests to remove www (i.e., all requests to example.com will go to www.example.com).

When removing "www" breaks WordPress

WordPress is unique in that it requires the URL to either force www or remove www from the domain name. If your database is forcing www but your panel is forcing it’s removal (or vice versa), you’ll see a redirect loop error such as this:

01 Removing www from your domain.fw.png

The solution is to make sure the option in your DreamHost panel matches what you selected within the WordPress configuration. View the Change Wordpress Site URL article for instructions on how to confirm which version is set within WordPress.

Using phpMyAdmin to update the URL in WordPress

  1. Go in to phpMyAdmin.
  2. Update the wp_options table and set siteurl and home values to http://example.com (without the www, and it should start redirecting properly).

Removing "www" through an .htaccess file

To automatically remove the www from the beginning of your domain, add the following mod_rewrite rule to your htaccess file. If you don't have that file, create it in a text editor and then upload it to your root directory:


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

See also