Why You Need to Redirect Non-WWW Traffic to WWW (or Vice Versa) and How to Do It Right

3 min read
8-Jan-2025 4:15:00 PM
Why You Need to Redirect Non-WWW Traffic to WWW and How to Do It Right
4:02

When it comes to your website’s domain, there’s one small technical detail that can have a big impact on your SEO, user experience, and overall site performance: how you handle the non-WWW and WWW versions of your site. If you’re not automatically redirecting traffic from one version to the other, you’re missing out on some important benefits and potentially creating harmful issues.

The Problem with Not Redirecting Non-WWW to WWW (or the Other Way Around)

If your website is accessible via both the WWW and non-WWW versions (e.g., "www.example.com" and "example.com"), it creates a few issues:

  1. Duplicate Content Issues: Search engines may see the two versions as separate websites with identical content, which can lead to duplicate content penalties and dilute your SEO efforts.

  2. Diluted Link Equity: If backlinks point to both versions, your site’s authority is split between them instead of being consolidated, which weakens your overall search ranking.

  3. Inconsistent User Experience: Users who access different versions of your site might face confusion or even errors, especially if cookies or sessions behave inconsistently across versions.

  4. Security Concerns: HTTPS certificates might not be properly configured for both versions, leading to security warnings or failed connections.

How to Properly Redirect Non-WWW Traffic to WWW (or Vice Versa)

To avoid these issues, it’s best practice to choose a preferred version (either WWW or non-WWW) and implement a permanent 301 redirect from the other version. Here’s how you can set it up based on different environments:

1. Configuring Redirects via .htaccess (for Apache Servers)

If your site is hosted on an Apache server, you can use the .htaccess file to set up the redirect:

To redirect non-WWW to WWW:

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

To redirect WWW to non-WWW:

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

2. Configuring Redirects in Nginx

If your site is hosted on an Nginx server, you can add the following configuration to your server block:

To redirect non-WWW to WWW:

server {
server_name example.com;
return 301  https://www.example.com$request_uri;
}

To redirect WWW to non-WWW:

server {
    server_name www.example.com;
    return 301 https://example.com$request_uri;
}

3. Redirects via DNS Settings

While DNS redirects are possible, they’re generally not recommended for handling WWW and non-WWW traffic because they don’t offer the same control as server-level redirects. Instead, it’s best to implement 301 redirects through your server configuration or CMS.

4. Using a CMS like HubSpot or WordPress

If you’re using a CMS like HubSpot or WordPress, you can usually configure your preferred domain through the platform settings. These platforms often provide built-in options to set up canonical URLs and handle redirects automatically.

  • HubSpot: Navigate to Settings > Domains & URLs and choose your primary domain.
  • WordPress: Go to Settings > General and ensure your site URL is consistent across both fields.

Best Practices for Redirecting Non-WWW to WWW (or Vice Versa)

  1. Choose One Version: Pick either WWW or non-WWW as your canonical version and stick with it.

  2. Implement 301 Redirects: Use permanent (301) redirects to ensure that search engines and users are always directed to your preferred version.

  3. Update Google Search Console: Add both versions of your site to Google Search Console and set your preferred domain.

  4. Test Your Redirects: Use tools like redirect checkers or curl commands to ensure that your redirects are working correctly.

  5. Check HTTPS Configuration: Ensure that your SSL certificate covers both the WWW and non-WWW versions to avoid security warnings.

The Bottom Line

Redirecting non-WWW traffic to WWW (or vice versa) is more than just a technical detail—it’s an essential part of your SEO, security, and user experience strategy. By setting up proper redirects, you’ll consolidate link equity, avoid duplicate content issues, and provide a consistent experience for your visitors.

If you’re not sure how to configure your redirects properly, reach out to ThinkFuel. We can help you optimize your website for better performance, SEO, and security.

Table of contents

Get Email Notifications