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 <a href="https:\/\/pagely.com\/blog\/wordpress-security-action-plan\/">securing of a website<\/a> 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.\r\n\r\nIn 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.\r\n<h2>Reasons to Use WWW<\/h2>\r\nAt first glance, it might not seem like there's a whole bunch of difference between the Zapier non-www URL:\r\n\r\n<img class="aligncenter size-full wp-image-17417 lazy" src="https:\/\/pagely.com\/wp-content\/uploads\/2015\/04\/Zapier-non-WWW.png" alt="Zapier non-WWW" width="900" height="290" \/>\r\n\r\nAnd the Salesforce www URL:\r\n\r\n<img class="aligncenter size-full wp-image-17418 lazy" src="https:\/\/pagely.com\/wp-content\/uploads\/2015\/04\/Salesforce-WWW.png" alt="Salesforce WWW" width="900" height="160" \/>\r\n\r\nBoth are located on an encrypted connection (as evidenced by the https:\/\/ prefix). And they both use a clear and concise .com domain name.\r\n\r\nHowever, there is a reason why one of those websites uses <em>www<\/em> and the other does not.\r\n\r\nLarger websites that contain subdomains must use www. Ultimately, it boils down to how the visitors' browsers handle cookies.\r\n\r\n<b>With www<\/b>, browsers store cookies for the website as a whole, including all subdomains.\r\n\r\n<b>Without www<\/b>, 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.\r\n\r\nAside from that one (very good) reason, the difference between www and non-www is superficial.\r\n<h2>How to Add WWW in WordPress<\/h2>\r\nFor 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.\r\n\r\nJust 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:\r\n<ul>\r\n \t<li>The web address on the frontend for visitors.<\/li>\r\n \t<li>The login URL for you and other WordPress users' backend access.<\/li>\r\n \t<li>The functioning of internal and external links pointing to the website.<\/li>\r\n<\/ul>\r\nBefore adding www in WordPress, read the following instructions thoroughly.\r\n<h3>1. Add WWW in the WordPress Admin<\/h3>\r\nFrom the WordPress dashboard, visit <b>General Settings<\/b>. On this screen, you'll need to update these two fields:\r\n\r\n<img class="aligncenter size-full wp-image-17425 lazy" src="https:\/\/pagely.com\/wp-content\/uploads\/2015\/04\/General-Settings-Update-1.jpg" alt="General Settings Update" width="800" height="494" \/>\r\n\r\nAdd <em>www.<\/em> after "https:\/\/" and hit <b>Save Changes<\/b>.\r\n\r\nWordPress should instantly log you out at this time. If it doesn't, you'll want to do this on your own.\r\n\r\nTo log back in, enter your admin URL into the browser window. This time, however, add <em>www.<\/em> to it.\r\n\r\nIf you can't log in after doing this, you need to <a href="https:\/\/support.pagely.com\/hc\/en-us\/sections\/114094024851-Caching-PressCACHE-">refresh the server cache<\/a>. If you continue to experience issues, use the next option.\r\n<h3>2. Add WWW with the wp-config.php File<\/h3>\r\nIf you want to hard-code the domain name change into the website, use the wp-config.php file to do so.\r\n\r\nVisit 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:\r\n\r\n<code>define( 'WP_HOME', 'https:\/\/www.better-businesses-etc.com' );\r\ndefine( 'WP_SITEURL', 'https:\/\/www.better-businesses-etc' );<\/code>\r\n\r\nJust remember to replace <em>better-businesses-etc.com<\/em> with your domain name. When you're done, save your changes.\r\n\r\nOne quick thing to note:\r\n\r\nThe 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.\r\n<h3>3. Perform a Database Search and Replace<\/h3>\r\nDepending on your plugins and theme, you might need to also perform a search and replace on the database to change all other references of the old non-WWW URL to the new one. The easiest way to do this is through WP-CLI.\r\n\r\nMore information on doing this can be found on our <a href="https:\/\/support.pagely.com\/hc\/en-us\/articles\/203339430#header-search-replace" target="_blank" rel="noopener noreferrer">Performing a Search and Replace with WP-CLI<\/a> documentation.\r\n<h3>Why You Should Implement a 301 Redirect<\/h3>\r\nIf 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?"\r\n\r\nHere's the thing:\r\n\r\nIt'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.\r\n\r\nTo 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.\r\n\r\nCreating 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.\r\n\r\nBottom 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.\r\n\r\nThen, when you've committed to your URL, set up a <a href="https:\/\/pagely.com\/blog\/wordpress-redirects\/">301 redirect<\/a>.\r\n\r\nGo to your domain manager and configure a 301 redirect to push traffic from the non-www:\r\n\r\n<code>https:\/\/better-businesses-etc.localhost<\/code>\r\n\r\nTo the www URL:\r\n\r\n<code>https:\/\/www.better-businesses-etc.localhost<\/code>\r\n\r\nThis ensures you capture all web traffic looking for your brand who might stumble on the wrong or older version of your URL.\r\n<h2>Final Thoughts<\/h2>\r\nTo www or not to www? That was the question here today.\r\n\r\nAs 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.