To WWW or not to WWW

Photo by Hitarth Jadhav from Pexels

Should I use WWW or not in my URL

The short story: It does not matter as long as your DNS records are set up properly to include both and you stay consistent with your patterns. It is recommended not to mix www and non-www URLs for SEO or if your subdomains requires cookies.

Twitter uses no www and forces a non-www redirect, however Facebook and Instagram force a www redirect when typed in without


The long story: Today I had to fix a job from July where I had done a quick website transfer from host A to host B. Recently client's website that stopped working (since when I do not know) and no-one knew why. It turned out that the DNS records were changed after the domain transfer, removing the A name record and having a www CNAME pointing to a host name. The original Wordpress installation additionally had the non-www URL set, redirecting all traffic to causing it to error out.

I fixed this by:

  • Changing the WordPress base URL
  • Manually changing non-relative WordPress URLs

I did not have access to fix this by:

  • Setting up a CNAME record to redirect non-www requests. Steps detailed below on how to do this

The following did not work to fix this

  • Redirecting the non-www URL to www with a .htaccess file

The fix

How to change Wordpress 4.x base URL

This will require you to either have database access or admin access

With admin access:

Wordpress Site URL Admin Access
Under the Settings > General tab change your WordPress Adress (URL) to include or exclude www


Without admin access, but with database access:

WordPress Site URL Database Access
Under the _options table change your siteurl to include or exclude www


How to change DNS records to include www and non-www redirects (Cloudflare):

With an A name record (IP)

Redirect A name record IP


Without A name. Only CNAME record if your host forces it

Redirect CNAME record


Forcing a www or non-www .htaccess redirect


Additional reading:

To www or not to www – Should you use www or not in your domain?
www vs. non-www: Which Is Better for SEO?
Should you use “www” in your URL or not?