If you would like to exclusively use either the www or non-www version of your domain, this can be through the redirects area of cPanel. Redirecting a domain to either the www version or non-www version is a little different from redirecting one domain to another, so we've created this article to walk you through how to do either one.

This type of redirection can help with URL canonicalization by search engines. URL canonicalization refers to the process by which a search engine decides which version of your site's URL is best to display in search results. By redirecting to one version of your site, you will have more control over which URL appears in search results. Per Google Webmaster Guidelines, this may also help to limit possible dilution of page rank that can occur if Google can't determine which version of your URL should be preferred.

First, you will want to decide which version of your site you prefer. This is really a personal preference and the only important thing is to be consistent. So, it's best to pick one up front and stick with it.

Redirecting Your Domain to www URL.

  1. Begin by logging into cPanel
  2. Select the Redirects icon under the Domains area of your cPanel home page.


  3. Keep the Type as the default, Permanent(301).
  4. Select your domain name from the drop down menu on the next line.
  5. In the redirects to text box, type in the full URL of your domain, including www (e.g. http://www.yourdomain.com).
  6. Select the radio button next to Do Not Redirect www.
  7. Click the Add button to add your redirect


  8. You can test your redirect by typing in the non-www version of your domain into your browser address bar. You will be automatically redirected to the www URL.



Redirecting Your Domain to non-www URL

  1. Begin by logging into your cPanel account.
  2. Click on the Redirects icon under the Domains area of your cPanel home page.


  3. Keep the Type as the default, Permanent(301)
  4. Select your domain name from the drop down menu on the next line.
  5. In the redirects to text box, type in the full URL of your domain, without the www (e.g. http://yourdomain.com).
  6. Select the radio button next to Only redirect with www.
  7. Click the Add button to add your redirect


  8. If you want to test your new redirect, type in the www version of your domain name into your browser. You will be redirected to the non-www URL for your domain.

    testing-non-www-redirect-1 testing-non-www-redirect-2

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Did you find this article helpful?


2012-11-06 2:55 am
Great article on setting up the redirect.

Would it be best to check the Wild Card Redirect also? Won't this further help URL canonicalization so that all pages on the site use the same domain.

For example, mydomain.com/news.html would get redirected to www.mydomain.com/news.html
17,314 Points
2012-11-06 4:02 am
Hello Chuckyaynesphoto,

If you are trying to make all of your URLs redirect in that fashion, then yes, that is a very good idea.

If you have any further questions, please contact technical support or leave a comment at the bottom of the page.


Arnel C.
n/a Points
2015-08-08 6:55 pm

im creating 301 redirect for cannocial for seo purpose but while opneing the link its showing a path ending with .html...i dont want to show .html while link is open

12,339 Points
2015-08-10 5:52 pm
Hello prashant,

Thank you for contacting us. Here is a link to a helpful guide I found via online search, on Removing file extensions using htaccess.

You may have to customize the code, depending on your other .htaccess rules.

Thank you,
n/a Points
2015-10-28 11:53 am

Thanks for your help :)

n/a Points
2018-04-06 11:03 pm

How come my domain is always showing www no matter how I redirect it to a non www name.  eg.  typing abc.com always shows up www.abc.com on the browser, I just want it to abc.com without www.

619 Points
2018-04-06 11:11 pm
The redirect described in this article should work to force www.abc.com to abc.com. However, if you are using a Content Management System (CMS) like WordPress for example, you would need to configure WordPress to use the domain without "www", otherwise it may result in undesired behavior. If you are using another CMS, let us know which one, we may have a guide to assist you with it.
n/a Points
2018-08-31 10:44 am

Hi, thanks for this

I did the redirect from www. to non-www (the second one). When I tried to load the website I got the error too many redirected.  This occured when I tried the url with the www. and without.

Any ideas?

536 Points
2018-08-31 10:27 pm
I recommend ensuring the A records for [yourdomain] and www.[yourdomain] point to the same server. Then check that there aren't redirects created elsewhere - within the website, a CDN, etc..
n/a Points
2018-09-16 6:11 am

Thank you for your response.

What is an A records, and where can I check where they point to?  I'll check the website too.

Thanks in advance!

619 Points
2018-09-17 8:12 pm
An A record is a type of DNS record that is used to translate your domain name into a computer readable IP address. These records are configured in the nameserver that your domain is pointed to. If you are pointed to WebHosting Hub's nameservers, then you can view the DNS records from your cPanel. If you are not pointed to WebHosting Hub's nameservers, you should look for these records where you maintain the DNS for your domain.
n/a Points
2018-10-21 8:44 pm

Thanks for sharing a very good and informative article, and I have added the non-www to www 301 redirection code in the .htaccess file, and I also do the same steps that u mentioned above in the article for "redirecting www URL". I want to know that should i delete the code in the .htaccess file or not?

Here is the code i was added in the .htaccess file.

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example.com

RewriteRule (.*) http://www.example.com/$1 [R=301,L]


619 Points
2018-10-22 6:07 pm
You're welcome Moeez. cPanel adds the code for the redirect to the .htaccess file. You do not need to add additional code. I do not recommend removing the code, otherwise the redirect will not work anymore. I hope this helps!

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.