Setting up the main website mirror

Detailed setup instructions. Read it and you will succeed!
A safe configuration sequence

Choose the primary hostname and ask your host to enable the redirect

A new site commonly uses the shorter non-WWW address. For an established site, retain the version already used in advertising, links and search.

  • both variants must exist in DNS;
  • SSL must cover both hostnames;
  • the rule must point in one direction only.
Choosing a primary hostname, configuring one redirect rule and verifying the result
Choose the address, configure one direction, then verify the result.

Ready-to-send support message

Replace the domain and reverse the direction if needed.

Hello,
Please configure a permanent 301 or 308 redirect for example.com
from www.example.com to example.com.
Preserve page paths and query strings, redirect directly to HTTPS
and avoid a chain of multiple hops.
Please confirm whether this is included in the hosting plan. Thank you.

Before making changes

  1. Confirm which hostname is already in use.
  2. Back up the configuration.
  3. Check DNS and certificate coverage for both versions.
  4. Identify the server or find the “Primary domain” setting.

Technical notes

Apache: remove WWW

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]

Apache: add WWW

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L,NE]

Nginx alternative-host block

server_name www.example.com;
return 301 https://example.com$request_uri;

The full block, ports and SSL must match the server. Validate configuration before reloading.

Avoid a chain

Bad:  http://www.example.com → http://example.com → https://example.com
Good: http://www.example.com → https://example.com
  • update internal links and canonical tags;
  • check sitemap.xml, CMS, analytics and advertising;
  • clear server and CDN caches;
  • run the manual verification.

Bulk changes to links, canonical, sitemap.xml, robots.txt and advertising URLs are separate tasks. Restore the backup if a loop appears.