To WWW or Not to WWW? How to Add WWW to Your URLs in WordPress

There are a number of reasons you might need to change the URL of your WordPress site. Changes to the brand typically prompt updates to the domain name. The securing of a website will require a switch from http to https. Then, of course, there’s the matter of updating a website from www to a naked (non-www) URL.

In the following tutorial, I’ll explain why you might want to add www to your URLs in WordPress and provide you with a couple methods for doing so.

Reasons to Use WWW

At first glance, it might not seem like there’s a whole bunch of difference between the Zapier non-www URL:

Zapier non-WWW

And the Salesforce www URL:

Salesforce WWW

Both are located on an encrypted connection (as evidenced by the https:// prefix). And they both use a clear and concise .com domain name.

However, there is a reason why one of those websites uses www and the other does not.

Larger websites that contain subdomains must use www. Ultimately, it boils down to how the visitors’ browsers handle cookies.

With www, browsers store cookies for the website as a whole, including all subdomains.

Without www, browsers have to store a different cookie for every subdomain request. As you can imagine, the process is highly inefficient and slows down loading times on the website as a result.

Aside from that one (very good) reason, the difference between www and non-www is superficial.

How to Add WWW in WordPress

For those who would like to add www to your WordPress website–regardless of whether it’s for a site with multiple subdomains–there are a couple of ways to do this.

Just be careful. One wrong move and you could end up with the white screen of death. It might be a simple to execute the change from non-www to www, but it will have far-reaching effects on your website. It will change:

  • The web address on the frontend for visitors.
  • The login URL for you and other WordPress users’ backend access.
  • The functioning of internal and external links pointing to the website.

Before adding www in WordPress, read the following instructions thoroughly.

1. Add WWW in the WordPress Admin

From the WordPress dashboard, visit General Settings. On this screen, you’ll need to update these two fields:

General Settings Update

Add www. after “https://” and hit Save Changes.

WordPress should instantly log you out at this time. If it doesn’t, you’ll want to do this on your own.

To log back in, enter your admin URL into the browser window. This time, however, add www. to it.

If you can’t log in after doing this, you need to refresh the server cache. If you continue to experience issues, use the next option.

2. Add WWW with the wp-config.php File

If you want to hard-code the domain name change into the website, use the wp-config.php file to do so.

Visit your control panel and open your file manager or FTP manager. Then, locate the wp-config.php file and add the following lines of code:

define( 'WP_HOME', 'https://www.better-businesses-etc.com' );
define( 'WP_SITEURL', 'https://www.better-businesses-etc' );

Just remember to replace better-businesses-etc.com with your domain name. When you’re done, save your changes.

One quick thing to note:

The wp-config.php settings will always override the domain name settings in the WordPress dashboard. If you experienced issues trying to add www in WordPress and clearing the cache didn’t work, it’s probably because someone already hard-coded the non-www URL into this file. Do a search for the lines above and edit them to reflect the domain name structure you need them to be.

Like this content? Meet Pagely.

Why You Should Implement a 301 Redirect

If you’re wondering, “Why don’t I just create a version of my website at www and one at non-www? Wouldn’t that be easier?”

Here’s the thing:

It’s not ideal to have both a www and non-www version of a website in existence. There are a couple of reasons for this.

To start, Google indexes website content and associates it with the full URL. If you launched your WordPress site with a non-www domain and then decide a year down the line you want to change it, Google will have to index the www version of it from scratch and you’ll lose all that good link juice you accumulated.

Creating a www mirror image of the non-www website would pose problems in SEO as well. Google bots don’t understand that you’re doing this for the purposes of capturing any and all traffic that goes to the www or the non-www of your website. Google bots will see this and try to rank both versions of the site simultaneously. So, not only will your content compete against itself, but it’ll suffer a penalty for listing duplicate content in search.

Bottom line: you should choose whether to add www to your WordPress site or just leave it out altogether. But make a choice and stick to it.

Then, when you’ve committed to your URL, set up a 301 redirect.

Go to your domain manager and configure a 301 redirect to push traffic from the non-www:

https://better-businesses-etc.localhost

To the www URL:

https://better-businesses-etc.localhost

This ensures you capture all web traffic looking for your brand who might stumble on the wrong or older version of your URL.

Final Thoughts

To www or not to www? That was the question here today.

As you have learned, there are clear reasons why large websites with subdomains should use www. For everyone else, the choice is yours to make. If you like how it looks, or you want to be 100% sure that people who know your brand name can find you, go ahead and add www to your WordPress site. Just make sure you follow the steps above to ensure it’s properly implemented.

16 Comments

  1. Andrew
    Andrew

    Hi Shaun,

    I’ve been trying to do exactly this, but for some reason I can’t get my site to load.

    I’ve been trying to adjust my WP settings to make the URL begin with http:// www instead of http://

    I have also attempted a more thorough database rewrite where I replace every mention of the http:// url with http:// www, but under no circumstances can I get the site to load at the end. If I reverse all the changes, I can get back on the plain http:// url.

    Any ideas what’s going wrong here?

    Reply

    1. Alé Yánez
      Alé Yánez

      Same problem here. How do you fixed it?

  2. Don Macfarlane
    Don Macfarlane

    Not sure how to interpret what you write. Are you saying that wordpress AUTOMATICALLY does the redirect non-WWW to WWW (and vice versa) and that the change in settings is for those who want to make a change overall? I have a WordPress site that works without WWW but does not work with it. You seem to imply that the redirect is a built-in WordPress feature that works regardless of what is specified in settings > general.

    Reply

  3. Camus
    Camus

    Unfortunately, it’s not always that straightforward. If you have certain settings in your .htaccess, then simply changing via the wordpress dashboard can cause issues.

    Reply

  4. ayesha ali
    ayesha ali

    My site is gomeri.com How i can get this with www domain name. It is online shopping store.

    Reply

  5. Subodh Gupta
    Subodh Gupta

    Do i have to change or edit url in c-panel after changing the (www) from wordpress general settings?

    Reply

  6. Hemed
    Hemed

    Worked for me

    Reply

  7. Ellen Finkelstein
    Ellen Finkelstein

    My new site doesn’t have www in the Site URL and WordPress URL settings. But when I try to type http://www.domain.com, I get a message that there were too many redirects. Typing just domain.com without the www. works fine. Why doesn’t the automatic redirect work? I’m not aware of any other redirects going on.

    Reply

  8. Ganesh Sutradhar
    Ganesh Sutradhar

    Nice Post

    Reply

  9. Syed Muhammad Ali
    Syed Muhammad Ali

    it really helped… thank you

    Reply

  10. Sarif
    Sarif

    I have done it but still the browser doesn’t direct to the preferred www ?

    Reply

  11. Andy Barzyk
    Andy Barzyk

    sorry but the option above in settings is now gone.

    Reply

  12. Deniz Humması
    Deniz Humması

    Thank you very much. Helped us a lot.

    Reply

  13. abdelmajeed
    abdelmajeed

    Thank You !

    Reply

  14. Mary
    Mary

    It works to me. Thank you very much.

    Reply