Sometimes you want to force the use of WWW in front of your domain. There is generally very little difference on a site using a WWW prefix vs not using it. There are two reasons though why you might want to force it:
- “www” stores cookies for the domain and all subdomains. Without www, separate cookies are stored for each subdomain. So, for large sites with many requests going between subdomains it might be a tab bit faster when using “www”
- An existing site already uses “www” and simply wants to continue doing so to preserve SEO rankings & links
To force the use of WWW, just update your WordPress records on the WordPress settings screen.
- Go to SETTINGS → GENERAL
- Add the ‘www’ in the WordPress Address and Site Address fields.
You can confirm that the change has been made by going to the permalinks screen:
- Go to SETTINGS → Permlinks
- Each permalink option should show the “www” in it.
Click the SAVE CHANGES button to update your permalinks.
You may need to update your DNS pointers as well to create a WWW entry.
Moving between HTTP and HTTPS #
When you switch between HTTP and HTTPS (or vice-versa), we update the domain back to its default. So, you will need to make the change twice.
First, add the ‘www’ before turning on HTTPS. This allows us to get a certificate for both ‘www’ and non-www domains.
After HTTPS is turned on, go back and add ‘www’.
Search and Replace #
If you’re going from a “mydomain.com” to “www.mydomain.com” then you’ll want to use a WordPress search and replace tool to conduct two search & replaces on your database:
- Search for “http://mydomain.com” and replace with “http://www.mydomain.com” (or “https://www.mydomain.com” if using ssl)
- Search for “https://mydomain.com” and replace with “https://www.mydomain.com”
Do NOT search for just “mydomain.com” and replace with “www.mydomain.com”. If you do you might end up with entries such as “http://www.www.mydomain.com”.
We have a simple search and replace tool in the SITE detail screen. But for more sophisticated search & replace function we use the search and replace tool in UPDRAFT PLUS (which is our backup plugin). There are other 3rd party tools that can be used to do this as well.
Other Notes #
Don’t forget to set up your CNAME for the “www” prefix in your DNS if it’s not already present!
More Topics In Tips, Techniques & Education. #
- Increase WordPress Upload Size
- How To Access The Entire Server via sFTP
- How Do I Limit PHP Workers For Each Subdomain On A Multisite?
- How To Generate an SSH Key Pair
- Considerations For A Large Number Of Sites On A Single Server
- All The Possible WP-CONFIG.PHP Constants For Core WordPress
- Using MIGRATE GURU To Import Sites
- Local & Remote Statuses On Servers
- CORS Example: Allow Access to Resources Between www and non-www Domains
- Import Sites
- Transferring Sites Between Servers
- Monit vs Netdata vs Monitorix vs GoAccess
- Resolving Common Issues With CloudFlare
- View Used Disk Space For A Site
- Customizing Front-end Styles
- How To Generate An SSH Key-Pair With Termius
- How To Change Your DNS Server
- Restoring From AWS S3 Into A New Site or Server
- Tweaking The Malware Scanner
- Handling Low Disk Space Conditions
- Useful OpenLiteSpeed Commands
- Alias Domains
- Custom SSL Certificates
