Skip to main content

Website Configuration Guides

How to Redirect www to Non-www Without Splitting Your SEO

Pick one hostname - with or without www - and force every browser and search engine to land there with a single 301 rule.

301

The permanent redirect status code to use here, not 302

1

Canonical hostname search engines should index, not two

Free

Auto-renewing SSL that covers both www and non-www

24/7

Human support if a redirect rule causes a loop

In short

Here's how to redirect www to non-www: add a rule to your .htaccess file that checks the requested host for the www version and issues a 301 redirect to the bare domain, or use your hosting panel's redirect tool instead. The reverse direction uses the same logic with the condition flipped, stopping search engines and analytics from treating www and non-www as separate sites.

Doing this once, early, prevents duplicate content warnings and traffic reports that quietly split a single audience in two.

Every domain technically has two addresses the moment DNS is set up: the bare domain and the www version, and browsers, search engines and analytics tools all treat them as distinct hostnames unless something explicitly tells them otherwise. Visit both versions of a site with no redirect in place and you'll get two working pages with identical content, sitting at two different URLs - which is precisely the setup search engines flag as duplicate content and analytics tools quietly report as two separate audiences.

The fix is a single 301 redirect that picks one canonical version and sends every request for the other one there automatically. This guide covers the .htaccess method, the DNS-level approach, and the reasoning for picking one hostname over the other, plus what a cPanel-style redirect tool does for anyone who'd rather not hand-edit server config files.

Why Splitting www and Non-www Hurts SEO and Analytics

Search engines crawl and index URLs, not domains in the abstract, so https://example.com and https://www.example.com are two separate entries in their index until a canonical signal tells them otherwise. Left unresolved, any backlink pointing to one version doesn't count toward the other's authority, effectively splitting the ranking signal a site could otherwise consolidate in one place.

Analytics tools have the same blind spot: a visitor landing on the www version and another landing on the non-www version register as traffic to two different properties unless tracking code and configuration explicitly unify them. That usually shows up as an unexplained dip in reported sessions compared to what server logs actually show, purely because the numbers are split across two hostnames instead of one.

How to Redirect www to Non-www Using .htaccess

On an Apache-based server, the standard approach is a rewrite rule placed near the top of the .htaccess file in your site's root directory, before any WordPress or application-specific rules: RewriteEngine On, followed by RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC], and RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]. Swap in the actual domain and the rule catches every request to the www version and permanently redirects it, path and query string included.

The R=301 flag matters here - it tells browsers and search engines this is a permanent move, not a temporary one, which is what actually consolidates ranking signals onto the destination. Test it by requesting a few different URL paths on the www version and confirming each lands on the matching non-www page rather than a generic homepage redirect.

Doing the Reverse: Non-www to www With the Same Method

Some sites prefer www as the canonical version, often for historical or branding reasons, and the fix is the identical rule with the condition flipped: RewriteCond %{HTTP_HOST} ^example\.com$ [NC] followed by RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]. The logic doesn't favor either direction - what matters is picking one and applying it consistently everywhere, from internal links to the sitemap.

DNS needs to support whichever direction is chosen: a www hostname is usually a CNAME pointing at the bare domain or the hosting provider's address, while the bare domain itself typically needs an A record (or an ALIAS/ANAME record where a provider supports one) since a root domain can't always be a plain CNAME under the DNS spec.

Setting It Up Without Touching Code: cPanel-Style Redirects

A cPanel-style hosting panel usually includes a Redirects or Domains tool that sets the same 301 rule through a form: pick the source (www or non-www), the destination, and whether it's a permanent redirect, and the panel writes the underlying rule without anyone opening .htaccess directly. That's the faster route for anyone unfamiliar with Apache rewrite syntax.

Whichever method is used, confirm the SSL certificate covers both hostnames before relying on the redirect - a certificate that only covers one version throws a browser security warning before the redirect ever gets a chance to fire. Free auto-renewing SSL that covers both www and non-www by default avoids that failure mode entirely, and 24/7 human support is available if a rule ends up causing a redirect loop instead of a clean landing.

How to Redirect www to Non-www (or the Reverse)

One Canonical Address, Enforced at the Server Level

Choosing a canonical hostname is a five-minute decision. Enforcing it correctly - with the right redirect type, a certificate that covers both versions, and no conflicting rules further down the .htaccess file - is where most sites either get it right once or keep quietly leaking SEO signal for years.

Hosting Cheap's cPanel-style panel makes the redirect a form-based setting instead of a hand-edited rule, backed by free SSL on both hostnames, daily backups if an edit needs undoing, and 24/7 human support if a rule causes a loop instead of a clean redirect.

  • cPanel-style Redirects tool sets the rule without hand-editing .htaccess
  • Free auto-renewing SSL covers both www and non-www automatically
  • 24/7 human support if a redirect rule causes a loop
  • Daily backups protect your .htaccess file before you experiment with it

Why Hosting Cheap

What you get

cPanel-style redirect tool

Set a 301 rule between www and non-www through a form, without opening .htaccess.

Free SSL on both hostnames

Auto-renewing SSL covers www and non-www by default, so the redirect never hits a certificate warning first.

Daily backups

Restore .htaccess in seconds if a redirect rule is edited incorrectly.

24/7 human support

Get help tracing a redirect loop instead of guessing at which rule is conflicting.

Free managed migration

Existing redirect rules and .htaccess configuration move over when your site does.

30-day money-back guarantee

Confirm the fix holds and rankings consolidate before committing further.

How It Works

Get set up in a few steps

1

Pick your canonical hostname

Decide once whether www or non-www is the version you'll use everywhere.

2

Add the 301 rule

Use .htaccess or your panel's redirect tool to send the other version there permanently.

3

Test and update Search Console

Check several URL paths, then confirm the preferred domain in Search Console.

Included

Everything you need, on every plan

  • Pick one canonical hostname and use it in every internal link
  • Use a 301 permanent redirect, never a 302, for this rule
  • Place the RewriteCond/RewriteRule pair above other application rules in .htaccess
  • Confirm your SSL certificate covers both www and non-www
  • Test the redirect on several URL paths, not just the homepage
  • Update your sitemap to reference only the canonical hostname
  • Set the preferred domain signal in Google Search Console
  • Back up .htaccess before editing it directly

FAQ

Frequently asked questions

Should I use www or non-www as my canonical domain?

Either works for SEO as long as it's applied consistently - the choice usually comes down to branding preference or what a site has historically used in backlinks and marketing.

What's the difference between a 301 and a 302 redirect here?

A 301 tells browsers and search engines the move is permanent, consolidating ranking signals onto the destination; a 302 signals a temporary move and doesn't pass that consolidation the same way.

Will this redirect fix duplicate content issues in Google?

Yes, a consistent 301 redirect combined with a matching canonical tag resolves the duplicate content signal between the www and non-www versions of the same pages.

Can I set this up without editing .htaccess directly?

Yes, a cPanel-style Redirects or Domains tool sets the same rule through a form, which is the faster option for anyone unfamiliar with Apache rewrite syntax.

Will the redirect break if my SSL certificate doesn't cover both versions?

Yes, a certificate covering only one hostname triggers a browser security warning before the redirect can fire, which is why SSL that covers both versions matters as much as the rule itself.

Do I need to update anything after adding the redirect?

Update internal links, your sitemap, and the preferred domain setting in Google Search Console so every signal points to the same canonical hostname as the redirect.

Ready to Enforce One Canonical Hostname?

Set the redirect through a cPanel-style panel, backed by free SSL on both hostnames and 24/7 human support if anything loops.

Get Started