Why is nginx displaying the wrong website on my server? -


i have 2 websites: default-website.com, second-website.com.

when go second-website.com seeing default-website.com. not understand why happening. note default-website.com displays normal.

this setup:

  1. dns set both point @ same ip address.

  2. they both have own unique websites:

    /var/www/default-website.com/public_html/index.html  /var/www/second-website.com/public_html/index.html 
  3. this contents of /etc/nginx/sites-enabled:

    lrwxrwxrwx root root default-website.com -> /etc/nginx/sites-available/default-website.com  lrwxrwxrwx root root second-website.com -> /etc/nginx/sites-available/second-website.com 
  4. this contents of /etc/nginx/sites-available/default-website.com:

        server {         listen 80 default_server;         listen [::]:80 default_server ipv6only=on;         root /var/www/default-website.com/public_html;         index index.html index.htm;         server_name default-website.com;         location / {                                 try_files $uri $uri/ =404;         }     } 
  5. this contents of /etc/nginx/sites-available/second-website.com:

        server {         listen 80;         listen [::]:80;         root /var/www/second-website.com/public_html;         index index.html index.htm;         server_name second-website.com;         location / {                 try_files $uri $uri/ =404;         }     } 

can see wrong here? appears set correctly.

thank help.

i figured out.

i needed add "www." version of domain name nginx website config.

so needed make change:

server_name second-website.com www.second-website.com; 

it seems if tried go www.second-website.com couldn't find it, load default website default-website.com.

i able detect trying load second-website.com (loaded correctly) instead of www.second-website.com (redirected default-website.com).


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -