Posted on Leave a comment

How to convert a non-WWW WordPress site to WWW

UPDATE (Jun 6, 2019): Converting this site from non-WWW to WWW created a significant caching issue with WP-Rocket.

Namely, WP-Rocket had created a cached version of the non-WWW homepage, and this version remained inside the /wp-content/cache/ directory even after the conversion. This version continued to exist despite clearing the cache from the WP-Rocket settings.

Since the non-WWW cached version of the homepage referenced non-WWW images, it displayed blank areas instead of WWW images.

It was this cached version that Googlebot continued to crawl, and for several months Google displayed this outdated & faulty version in its index. (ie: Google continued to index the non-WWW homepage version instead of the WWW version, its cached version did not display any images, and styles for the social media buttons were broken for mobile phones.)

Deleting old cache files & folders from the /wp-content/cache/ folder on the server solved this problem immediately.


UPDATE (Dec 30, 2018): This site’s SEO took a big hit following the conversion from non-WWW to WWW. Therefore, conversion to WWW is not recommended unless absolutely required for using a content delivery network.


Ancient Greek Keyboard’s original domain URL was https://www.ancientgreekkeyboard.com, but was recently changed to https://www.ancientgreekkeyboard.com.

While using WWW in the domain name is said to result in slight improvements in site speed, security and scalability, the main reason for the change was so that a content delivery network could be used in the future (CDNs typically require sites to use WWW in their domain names).

The following procedure was used in converting this WordPress site from non-WWW to WWW:

  1. Use the Duplicator plugin to create a backup of the current site.
  2. Download the backup created by Duplicator to the local computer (and download the corresponding INSTALLER.PHP file as well).
  3. Download the current HTACCESS file at the root of the WordPress installation using Filezilla. Save a copy in a secure location on the local computer.
  4. Comment out all HTTPS redirection code in the HTACCESS file.
  5. Upload the edited HTACCESS file back to the root of the WordPress installation on the server.
  6. Download the WP-CONFIG.PHP file from the root of the WordPress installation on the server.
  7. Comment out:
    define('WP_HOME', 'https://www.ancientgreekkeyboard.com');
    and:
    define('WP_SITEURL', 'https://www.ancientgreekkeyboard.com');
    (If these statements are nowhere to be found in WP-CONFIG.PHP, then ignore this step.)
  8. Save WP-CONFIG.PHP file & upload it to the root of the WordPress installation on the server. (If the previous step was skipped, this step can be skipped as well.)
  9. On the WordPress administration page, go to: Settings > General.
  10. WordPress Address (URL) set to https://www.ancientgreekkeyboard.com.
  11. Site Address (URL) set to https://www.ancientgreekkeyboard.com
  12. Click the Save button.
  13. Automatically logged out of the WordPress administration page.
  14. Log back into the WordPress administration page.
  15. Check Settings > Permalinks to verify all permalinks include WWW. (They did.)
  16. Add & activate the Velvet Blues Update URLs plugin.
  17. Click the Update URLs link on the WordPress administration plugin page.
  18. Input Old URL: https://www.ancientgreekkeyboard.com
  19. Input New URL: https://www.ancientgreekkeyboard.com
  20. Click all checkboxes for updating URLs (except GUIDs).
  21. Click the Update URLs NOW button.
  22. Velvet Blues updated 131 content items, 19 attachments, and 34 custom fields.
  23. Also used Velvet Blues to update from HTTP to HTTP://WWW (ie: from https://www.ancientgreekkeyboard.com to https://www.ancientgreekkeyboard.com.) Two content items were thus updated. (This was unexpected, since I believed there were no HTTP URLs residing on the site.)
  24. Deactivate the Velvet Blues Update URLs plugin.
  25. Change WP-CONFIG.PHP to reflect the new WWW domain name:
    define('WP_HOME', 'https://www.ancientgreekkeyboard.com');
    define('WP_SITEURL', 'https://www.ancientgreekkeyboard.com');
  26. Change the salts in WP-CONFIG.PHP.
  27. Upload WP-CONFIG.PHP to the root directory of the WordPress installation.
  28. Automatically logged out of the WordPress administration panel.
  29. Log back into the WordPress administration page.
  30. Change the HTACCESS code in the root of the WordPress installation to automatically redirect URLs to HTTPS://WWW.
    ### First rewrite any request to the wrong domain to use the correct one (here www.)
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    ### Now, rewrite to HTTPS:
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  31. Update URL addresses in HTACCESS to refer to WWW.
  32. Save HTACCESS & upload to root directory of the WordPress Installation on the server.
  33. In the Child Theme folder, find the STYLE.CSS, STYLE-LOGIN.CSS, and FUNCTIONS.PHP files and change all references from non-WWW to WWW. (NOTE: If the latter two files don’t exist, then just update the STYLE.CSS file.)
  34. Save these three files & upload them to the Child Theme folder on the server. (Again, don’t bother with STYLE-LOGIN.CSS and /or FUNCTIONS.PHP if they don’t exist!)
  35. Check a few images in the Media Library to verify that the images now have the correct WWW URL.
  36. Check a few Pages & Posts that they have WWW URLs.
  37. If using a shopping cart plugin, go to the settings & change all URLs to include WWW.
  38. Change all URLs to WWW in whatever SEO plugin is being used.
  39. The Guest custom avatar was somehow reset to default settings during the entire process. Go to Settings > Discussion to set it correctly again.
  40. Clear the WP-Rocket cache (or the cache for whatever caching plugin you’re using, if any).
  41. On Google Webmaster Tools, delete the current non-WWW property. Add a new WWW property, verify it, and add a sitemap.
  42. Repeated the previous step for Bing Webmaster Tools.
  43. Updated references to WWW in the ROBOTS.TXT file, and uploaded to the server.

Other posts in this series:

  1. Manual eCommerce Site Setup On SiteGround: Day 1
  2. Manual eCommerce Site Setup On SiteGround: Day 2
  3. Manual eCommerce Site Setup On SiteGround: Day 3
  4. Manual eCommerce Site Setup On SiteGround: Day 4
  5. Manual eCommerce Site Setup On SiteGround: Day 5
  6. Manual eCommerce Site Setup On SiteGround: Day 6
  7. Manual eCommerce Site Setup On SiteGround: Day 7
  8. Manual eCommerce Site Setup On SiteGround: Day 8: (Site brought live)
  9. Manual eCommerce Site Setup On SiteGround: Week 2
  10. Manual eCommerce Site Setup On SiteGround: Week 3
  11. Manual eCommerce Site Setup On SiteGround: Week 4
  12. Week 5: Speed optimization tests
  13. Manual eCommerce Site Setup On SiteGround: Week 6
  14. How to convert a non-WWW WordPress site to WWW
Leave a Reply

Your email address will not be published. Required fields are marked *

All comments are moderated. It may take a few days before your comment is reviewed and approved.