In a recent article (in French), Google announced that the search engine would stop offering this option because it was perfectly able to detect when a site publishes the same content twice on its version with and without www.
If Google will therefore no longer allow webmasters to select a preferred version. It is also because it will automatically determine the version it considers the most suitable. However, for webmasters unhappy with display in search results. There are a few optimizations to guide Google in choosing which URL format to display in search results.
How to Encourage Google to Choose the Version with Or without Www of Your URLs?
To force Google to choose the version with or without www of your URLs in its search results , several options are available to you (these can be combined to maximize your chances of being taken into account by Google):
Define the preferred version of your URL in the link rel canonical tag located in the head of your site on each of your pages: as a reminder, the Maldives B2B list canonical tag is used to define a preferred version of a URL (especially when multiple URLs contain the same content for example).
Define the preferred version of your URL via a canonical HTTP header. The operation is substantially similar to the html link rel canonical tag. But the latter is configured differently and is not visible in the HTML code of a site. Configure 301 redirects from the non-preferred version to the preferred version (without www to version with www for example). These rules must be configured with regex so that they automatically apply to all the pages of the site. It is possible to configure them via the .htaccess file in particular.
List your favorite URLs in your sitemap that you will then declare in the robots.txt. If all the URLs in your sitemap are of the form with www. Google will tend to favor this version rather than the one without www.