Redirecting to www or non-www

Redirecting to www or non-www

Why Redirect to www or non-www?

Running your website on www or non-www URLs may be for aesthetic reasons, personal preference or to prevent redundant hostnames. It is recommended that you keep the hostname of your website the same throughout. Either with the www part or without the www part.

In WordPress, you have a homeurl and siteurl so the redundant hostnames issue is not a problem since WordPress will automatically redirect to ensure that the site is running on the same siteurl as it should be. Other applications may require your attention in this area though.

Google Analytics will also give you a “Redundant Hostnames” warning if you don’t.

You want to do a permanent, HTTP 301 redirect for this.

How to Redirect to www or non-www

There are two quick and easy ways of doing this on our servers.
Pick one of the two methods that you prefer to use. The first one is the easiest for most users.

1. Using cPanel to Redirect to www or non-www

This is easy to do with cPanel. Login to your cPanel to get started.

Go to Domains > Redirects on the cPanel main page.

Now depending on whether you prefer the URLs with the www part or without the www part, the instructions will differ a bit.

Redirect to www

cPanel Redirect From non-www to www

  1. Set the type to permanent which will give an HTTP 301 status code.
  2. Choose your main domain in this drop down.
  3. Leave the path empty, you want to redirect the entire domain.
  4. Specify the URL to redirect to with the “www” part in it.
  5. Choose “Do Not Redirect www“.
  6. Leave the “Wild Card Redirect” unchecked.

Redirect to non-www

cPanel Redirect From www to non-www

  1. Set the type to permanent to give a 301 HTTP status code.
  2. Select the main domain from the drop down menu.
  3. Leave the path empty, we want to redirect the entire domain.
  4. Set the URL to redirect to without the “www” part in it.
  5. Choose “Only redirect with www
  6. Leave the “Wild Card Redirect” unchecked.

2. Using .htaccess to Redirect to www or non-www

Simply put the following lines of code into your main, root .htaccess file.
In both cases, just change out domain.com to your own hostname.

Redirect to www

Redirect to non-www

Shares

WordPress Plugins

Start selling products, sending newsletters, publishing ads and more through your own WordPress website using our premium WordPress plugins.

Browse

Pin It on Pinterest

%d bloggers like this: