Why my site is opening my other site?

May 23, 2013 1.8k views
I have an unsolved problem here. I want to open my site rekamedia.com, but its opening my other site dzulfriday.com This is so frustrated. This is my nginx config for rekamedia.com (i am just showing the listen and server name part) server { listen 80; root /pathtomyroot; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name rekamedia.com; rewrite ^(.*) http://www.rekamedia.com$1 permanent; } This is my nginx config for dzulfriday.com (i am just showing the listen and server name part) server { listen 80; ## listen for ipv4; this line is default and implied root /pathtomyroot; index index.html index.htm index.php; # Make site accessible from http://localhost/ server_name dzulfriday.com www.dzulfriday.com; } Can someone help me? I don't know what could be the problem
2 Answers
Its ok now after i change my server_name for rekamedia to this:
server_name rekamedia.com www.rekamedia.com;

and remove this:
rewrite ^(.*) http://www.rekamedia.com$1 permanent;

But i dont know why it works. I add that rewrite things so theres always "www" to go to my site
I recommend separating the non-www domain to another server{} block and rewrite to http://www from there.
Have another answer? Share your knowledge.