Www.example.com seems to point to wrong sub-domain

Hi all, I have a strange issues. I have just deployed a WordPress site and in the process I created a sub-domain for testing purposes.

So the process is like:

  1. I created a site with sub-domain: ee site create staging.example.com --type=wp
  2. Testing and make sure everything is fine
  3. Created the actual site: ee site create example.com --type=wp

I expect that www.example.com will redirect to (or an alias of) example.com. But the fact is, it is redirecting to stage.example.com

On the DNS side, I have www.example.com with CNAME (alias of) example.com

What do I need to look at? Thanks.

I checked /opt/easyengine/sites/example.com/config/nginx/conf.d/main.conf and /opt/easyengine/sites/staging.example.com/config/nginx/conf.d/main.conf and found the following:

server {
	access_log   /var/log/nginx/access.log;
	error_log    /var/log/nginx/error.log;

	root /var/www/htdocs;

	server_name example.com;

    ...
}

and

server {
	access_log   /var/log/nginx/access.log;
	error_log    /var/log/nginx/error.log;

	root /var/www/htdocs;

	server_name staging.example.com;

    ...
}

So it doesn’t seem that www.example.com alias was created automatically?

www.example.com and example.com are two completely different websites within the ee world. If you want www.example.com to redirect to example.com, you need to setup a redirect in the nginx-proxy conf file. Do not make changes to the main conf, cut add a custom conf file with your changes.

Thank you for your response @lotusjeff. I have resolved my issues … the redirection happened on WordPress and it was 301 so my browser hanged on it.

But it is interesting that you said www.example.com and example.com are separate site in ee world. Yesterday when I was searching for a solution to my issue, I found this post and seems to suggest that www.example.com is added automatically as an alias by ee.

Not always. If you start with a www. site and then create a non www site, the redirect will not be present.