Problem Descripton
- You wish to set your preferred domain to avoid issues like redirect loops, cookie (logged in state) consistency problems, or combine URL reporting in search console and analytics
- Your website might not work with the www prefix
Problem Resolution
Begin by picking a domain format to use. There are a few variations for every URL that boil down to whether or not your website's URL uses HTTPS and whether or not it uses www.
For example here's 4 different combinations of the Websavers URL:
For Websavers, we chose https://websavers.ca as our preferred URL: you must pick one too!
Once you have chosen your preferred URL, ensure you've configured that URL to be the same everywhere: in Plesk, in your web application's configuration, and possibly in plugin configurations too. Here's how:
- Begin by logging in to Plesk
- Head to the Websites & Domains tab
- Find the domain you're having this problem with and choose the option called "Hosting Settings".
- CONFIG WEB SERVER: The "Preferred Domain" setting on this page will control the www and non-www preference, and enabling the option called "Permanent SEO-safe 301 redirect from HTTP to HTTPS" will enable HTTPS (its usually enabled by default). Set these values to match your preferred URL.
- CONFIG WEB APP: If you're using a web application like WordPress or Magento, Select "1-click web apps" or Installatron and click the wrench icon beside the site you're working on. Look for your URL in the list of settings and change it to ensure it matches your preferred URL. This will reconfigure WordPress to use your preferred URL without having to go into the WordPress settings.
- Login to your web app (ex: WordPress) and ensure any settings that reference the site URL have been updated to your chosen URL format. For WordPress very few plugins have their own URL config option, but other web applications may differ, so it can be worth checking the plugin configs if the above steps haven't resolved the issue.
Your browser will have probably cached the redirect, so even after making these changes, loading the site in your browser may still display the same error. When testing this solution, be sure to either try a different browser or clear your browser cache after each change you make. You can also disable your browser cache during testing.
Troubleshooting
Capital letters can also cause this problem -- be sure none of the above locations have any capital letters in the URL. If they do, you'll need to rename the domain/subdomain in Plesk to something totally different, then rename it again back to the original value but without the capital letters.