How To Redirect a Website from a Non-www to a www URL

March 18, 2023 / Web Development

How To Redirect a Website from a Non-www to a www URL

A website can have two different versions of its address, either with www (world wide web) or without, for example, or There are pros and cons to both: non-www addresses look cleaner and are easier to remember, while those with www can be helpful for website performance and prevent issues with SEO. If you use one version, it is possible to change to another and, in this post, we explain the steps you need to take to redirect your non-www URL to one with the www URL.

The Value of redirecting to www

Moving to a www URL provides several helpful benefits. Firstly, if you have a www domain, your website can redirect easier to another server if the server you are on is experiencing usage overload. As a result, in times of heavy traffic, you have some protection against poor performance or going offline.

A second benefit is that it removes search engine confusion. This is because search engines see the www version and the non-www version as separate websites. As result, without a redirect, they will struggle to know which version to rank and will consider that there is duplicate content, as both versions are identical.

The third benefit is to do with cookies. With a www address, you can use cookie-free subdomains by restricting cookies to either the root domain or a chosen subdomain. As a result, you can improve website speed and performance as the number of HTTP requests is reduced.

How to redirect from a non-www URL to www ?

Below we will explain a number of ways to redirect a non-www URL to a www URL. However, just in case you make a mistake along the way, we advise that you take a backup of your website before you start.

  • Redirecting from a non-www URL to www using cPanel
    One of the easiest ways to redirect to a www URL is to use the cPanel control panel. To do this, follow the steps below:

    Domain Name
    1. Log in to cPanel, navigate to Domains and then click on Redirects.
    2. In the Add Directs panel that opens, find the Type dropdown field and choose the Permanent (301) option.
    3. In the https?:// field below, find or enter the non-www domain that you want to redirect.
    4. Leave the path field (/) blank.
    5. In the ‘Redirects to’ field, type in the full www version of your website URL – e.g.,
    6. In the options below, check the ‘Do Not Redirect www’ option and leave ‘Only redirect with www’ and ‘Redirect with or without www’ unchecked. Make sure the Wild Card Redirect box also remains unchecked.
    7. Finally, click Add.

Your website should now be redirecting all visitors to the non-www version of your site to the www version.

  • Redirecting from a non-www URL to www using .htaccess
    An alternative way to redirect your site from non-www to a www URL can be done by editing your .htaccess file. This file is usually found in your website’s root directory and can be located using your file manager.You can edit the .htaccess file in several ways. These include downloading it from the server and modifying it with a text editor, such as Notepad, or by editing it within your control panel’s file manager (not all control panels allow this) or via a plugin.To enable a redirect from non-www to www, Make the following changes to your .htaccess file –Find the line RewriteEngine On in the .htaccess file, insert a new line below it and then add the following two lines of code. Note, you must replace the address in bold below with the address of your actual website. In the top line use your non-www address and in the bottom line use your www address.RewriteCond %{HTTP_HOST} ^ [NC]
    RewriteRule ^(.*)$$1 [L,R=301]Once you have finished and double-checked that both URLs are correct, save the changes. If you have edited within file manager or using a plugin, the redirect should now be working.

    If you have edited the .htaccess file by downloading it, make sure you have saved the file in the same format as the original. You will then need to re-upload it to the root directory. To make it easier to resolve problems if you have made a mistake, do not delete the original .htaccess file, simply rename it as .htaccess-old. That way, if your edits don’t work, you still have the original version to fall back on.


Redirecting a non-www URL to a www URL can have benefits for site performance and SEO. Enabling the redirect can be done by editing your .htaccess file or, much simpler, by using the cPanel Redirects tool. If you are looking for cPanel web hosting, check out our cloud-powered cPanel Hosting Plans.


  • Arjun Shinde

    I'm an experienced digital marketer with expertise in planning, SEO, SEM, and social media. I'm good at creating engaging content and optimising campaigns for a strong online presence.

    View all posts