How to make both www and non-www resolve without redirecting

Part of Cleavr’s logic is to redirect non-www traffic to www or www traffic to non-www depending on how the site is setup.

If www.example.com was used to create the site, then non-www traffic is configured to redirect to www.

If example.com was used to create the site, then www traffic is configured to redirect to non-www.

This is pretty important for SEO as you’ll want your site to indexed using one or the other. But, if SEO isn’t important in your case, for whatever reason, and you want both www and non-www to resolve without redirecting, then the best way to accomplish this is as follows:

Create the new site with example.com as the domain.

Then, after the site is created, in the Settings section, add www.example.com as an alias.

Next, you’ll need to SSH into your server and update the redirect.conf file which is located in etc/nginx/cleavr-conf/example.com/header/redirect.conf.

Essentially, just remove the redirect logic

server {
  include /etc/nginx/cleavr-conf/example.com/server.conf;
  server_name www.example.com;
  return 301 $scheme://example.com$request_uri;
}

Update to:

server {
  include /etc/nginx/cleavr-conf/example.com/server.conf;
}

Your site will now resolve when a user types in example.com or www.example.com without redirecting.

1 Like