Redirect www to non-www (or the other way round)

www.example.com and example.com are two different addresses, and visitors type both. Pick one as your main address and redirect the other to it with a permanent (301) redirect. Which one you pick does not matter for search engines; using only one does.

Why redirect one to the other

  • Nobody hits a dead end. If only one of the two is set up, everyone who types the other one sees an error.
  • Search engines see one site, not two. Links and rankings collect on one address instead of being split between two copies of the same pages.
  • HTTPS works on both. A common problem is a certificate that only covers one of the two names, so the other shows a security warning before any redirect can run.

First: is there a website on the domain?

The setup depends on whether the domain itself shows a website, or only redirects somewhere else.

The domain only redirects

For example, an old brand name that should send everyone to your new site. Then there is nothing to choose: add both old-brand.com and www.old-brand.com as sources of the same redirect, and point both to Redirect Ninja. The create form suggests the second one as soon as you enter the first. Together they count as one domain on your bill. Step-by-step guide.

Your website lives on one of the two

First check your website host or site builder. Many have a setting that redirects the other version for you; if yours does, use it. If it does not, or it only works over http://, Redirect Ninja can handle the version your site does not use, while the site stays where it is.

Set it up with Redirect Ninja

Only the version that should redirect goes into Redirect Ninja. The version your site lives on keeps its current DNS record and keeps pointing to your host.

www to non-wwwnon-www to www
Site lives onexample.comwww.example.com
Sourcewww.example.comexample.com
Destinationexample.comwww.example.com
DNS record to changeCNAME www → connect.redirectninja.comA @ → 75.2.75.160
Leave aloneThe record for @The record for www
  1. Click Create Redirect and enter the source and destination from the table.
  2. Do not add the suggested counterpart. The form offers to redirect the other version too (“Visitors may also type … Redirect it too?”). Here that is your website itself, so leave it out.
  3. Choose Permanent Redirect (301), and turn on Path forwarding and Query parameter forwarding in the advanced settings. Then www.example.com/pricing?ref=ad lands on example.com/pricing?ref=ad, not the home page. How forwarding works.
  4. At your DNS provider, replace the record for the source name with the one in the table. Delete any other A, AAAA or CNAME record for that same name. Leave MX and TXT records alone.

Once the source shows Verified, Redirect Ninja issues its certificate, so https:// on the redirected version works too. Pointing the bare domain somewhere other than an A record? Why the root domain needs an A record.

Test it

Enter the redirected version, with a path, in the redirect checker, for example http://www.example.com/pricing. You should see one or two hops ending on https://example.com/pricing with a 200, and a working certificate on every hop. Try https:// as well.

If the checker shows the redirect going back and forth between the two names, your host also redirects in the opposite direction. Turn that setting off, or pick the version your host prefers as the main one.

Tell search engines which one is main

The 301 redirect does most of the work. Help it along by using the main version everywhere you control: in links between your own pages, in your sitemap, and in the canonical tags of your pages. Which redirect type to choose.

Related guides

chat support ninja

Need fast & friendly support?

chat-support

Redirect domains like a ninja

Swift, secure, and effortless — redirect your domains with full HTTPS and ninja precision. Just enter your source and destination, we'll do the rest.