So having your website prepended with www has some technical advantages. Not having www is called a “naked domain name.” There’s a bunch a benefits to www. So I updated my sites to www and here was the process:
1. Update your WordPress database URLs
Using WP DB Migrate Pro, or some other tool, change your naked domain name (http://yoursite.com), to the new www version (http://www.yoursite.com). A tool like WP DB Migrate will find all the URLs and update them for you without you having to do a search and replace which can screw up.
2. Update the hard coded address in the wp-config.php file.
Open your wp-config.php file and find the below lines of code. These may not be there, but hard coding these in speeds up your site and prevents clients from screwing up the site by messing with these. These same addresses are found the WP admin General section, but you will be updating your wp-config.php file.
define('WP_HOME', 'http://www.yoursite.com');
define('WP_SITEURL', 'http://www.yoursite.com');
That’s all there is for your WordPress site. There’s no need to update the .htaccess file, WP automatically redirects to either preferred URL you’ve set.
3. Notify Google Search Console
Add your new www domain to Google Search Console and verify it. Then go to the (gear icon) in the top right-hand corner and click Site Settings > Preferred Domain, and select your new domain www. Setup up sitemaps and any other information necessary for SEO.
4. Retaining your social shares
If you’re concerned about social shares because of the domain change, use a plugin called Social Warfare (Pro) to retain shares across domain name changes, it’s only $30/year.