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

Thanks for sharing your insights, and here’s to making our websites the best they can be!

2 Likes

Your advice on handling www and non-www versions of a website is spot on, especially for those of us who are particular about SEO. It’s crucial to ensure that visitors have a seamless experience, regardless of how they type the website URL. Speaking from my own experience, I’ve found that incorporating a free SEO website analyzer into my routine has been tremendously helpful. It’s like having a virtual SEO assistant that constantly monitors your site’s performance, offering insights and recommendations to enhance your online presence. It’s become an indispensable tool for me in the ever-competitive digital landscape.

1 Like

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\ .olddomain. com
RewriteRule (.*) http://www. newdomain. com/$1 [R=301,L]

its also a method you can do as a spell :slight_smile: