-1

So, I had my webserver running fine, I like non-www domains so I would leave non-www active, but whenever user would type www, they could also access the non-www version normally.

Then I created a subdomain http://blog.example.com. Now all traffic that goes to www.example.com load blog.example.com instead of example.com

I'm using nginx on digital ocean.

What can I do to fix this?

sigmaxf
  • 119
  • 4

1 Answers1

0

There is a lot of stuff going on behind the scenes that determines which domain will load by default in an nginx installation. The easiest way to address you issue is to have the "server_name" directive set properly in your config file for example.com. Something similar to the following should address your issue:

server_name example.com www.example.com

This will tell nginx to load the specific example.com configuration for both the www and non-www domains.

Jenos
  • 636
  • 3
  • 5
  • good! what if I want to keep the "www" on the url when they access it? – sigmaxf Sep 14 '16 at 05:16
  • Take a look at http://stackoverflow.com/questions/7947030/nginx-no-www-to-www-and-www-to-no-www for www redirecting. – Jenos Sep 14 '16 at 05:17