How to Redirect www to non-www Using .htaccess in 2024

Ever wondered how to make your website’s address more straightforward? We’re here to help you with a simple task: changing your web address from ‘www’ to ‘non-www.’ No tech jargon, just easy steps using “.htaccess,” a handy tool. No need to worry if coding sounds scary – we’ve got your back. By the end of this guide, you’ll be a pro at improving your website’s web address without any hassle. Let’s learn how to Redirect www to non-www and make your website’s URL change as easy as a few simple clicks.

What is the impact of www or non www website in SEO

When it comes to Search Engine Optimization (SEO), it’s crucial to have a website’s URL set up properly. However, some websites face the challenge of having multiple URLs. 

For instance, a website might open with both “” and “” This situation can confuse search engines, making it unclear which version is the primary one to index and rank. 

To address this, it becomes necessary to ensure that your website’s URL is SEO-friendly. This not only prevents any negative impacts on search results but also ensures a seamless experience for users. 

Making your URL SEO-friendly is a small but powerful step toward optimizing your website’s visibility and performance.

What are some causes?

If your website opens with both www and non-www URLs, you might encounter a few challenges. 

For instance, all your uploaded items, like images, videos, and various files, may have URLs accessible through both www and non-www versions. This can confuse search engines, leading to potential issues with indexing and ranking. 

To check this, open any content on your website with its URL, and try adding www before your website name. If it opens correctly, your site’s redirection is likely fine. However, if it still opens with www, adjustments are needed. 

Another potential cause is canonicalization, where your site’s posts and content might appear as duplicate content to search engines. 

This happens when Google sees two different URLs for the same content. To fix these issues and maintain your site’s ranking, we’ll explore easy and effective solutions using cPanel in the next topic.

How to Redirect www to non-www Website?

When it comes to redirecting a website, there are various solutions, such as utilizing a Content Delivery Network (CDN) like Cloudflare, which allows setting up redirection rules.

Alternatively, we’ll explore a simple method using cPanel to edit the .htaccess file, making the process easy.

  • Access cPanel and locate the “File Manager.”
  • If you have multiple domains in multi-site hosting, navigate to your domain’s folder either within the public_html folder or directly inside a folder with your domain name.

If you can’t find the .htaccess file, click on the three dots at the top and choose the option “Show Hidden Files”.

for more information read this article
  • Inside your website’s folder, find the .htaccess file and edit it.
  • Add the provided code inside the .htaccess file, as shown in the image below.
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule (.*)$1 [R=301,L]
htaccess code
  • Save your changes. In the WordPress dashboard, go to Settings > General. Ensure that the “Site URL” matches the URL you set in the code (e.g.,
change website url using wordpress

By following these steps, you’ll notice that when you enter the website URL with ‘www,’ it will automatically redirect to the non-www version, enhancing your website’s consistency.

How to Redirect non-www to www Website?

The solution for redirecting non-www to www is remarkably similar to the previous steps. You’ll need to modify the code as provided below, replacing the website name accordingly. By following the same set of steps, your website, for instance, from ‘’ to ‘’ will undergo a seamless transition.

Ensure that you update the code with your specific website details.

[Updated Code: Redirect non-www to www]

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule (.*)$1 [R=301,L]

By making these adjustments, your website will efficiently redirect from the non-www version to the specified www version, ensuring uniformity across all URLs.


To sum it up, fixing how your website’s address looks is a big deal for SEO. Whether you’re switching from www to non-www or the other way around, just follow the steps we talked about. Keep it simple! You can use tools like Cloudflare or make small changes in cPanel. It’s like giving your website a little makeover. This not only makes search engines happy but also makes things easier for people visiting your site. So, make those tweaks, keep it friendly, and let your website shine bright online.

Frequently Asked Questions

What impact can website redirection have on SEO?

Proper redirection preserves SEO by preventing link juice splitting. Frequent changes or incorrect redirects may cause temporary ranking fluctuations. Use 301 redirects for permanency and update sitemaps.

How to redirect www to non-www using Cloudflare DNS?

In Cloudflare, create a Page Rule:* redirects to$1. This ensures a smooth www to non-www redirection.

Are there SEO issues when changing a website’s URL structure?

Yes, changing URL structure can pose SEO challenges. Handle redirects correctly, inform search engines, and update links and sitemaps for a smooth transition.

Can multiple redirects impact website speed and user experience?

Yes, multiple redirects can slow down a website and affect user experience. Minimize unnecessary redirects and regularly optimize for optimal performance.

Leave a Reply

Your email address will not be published. Required fields are marked *