Question
Domain names are indifferent
Hello,
I have followed this post and tried to make two domains work on a single server.
To make thing simpler, I don’t want to set up a default server.
/etc/nginx/sites-available/addbba.com
server {
listen 80;
listen [::]:80;
root /var/www/addbba.com/html;
index index.php index.html index.htm;
server_name addbba.com www.addbba.com;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
/etc/nginx/sites-available/matrixandcompany.com
server {
listen 80;
listen [::]:80;
root /var/www/matrixandcompany.com/html;
index index.php index.html index.htm;
server_name matrixandcompany.com www.matrixandcompany.com;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I bought two domains addbba.com and matrixandcompany.com both from GoDaddy, I made them forward and mask to the IP 178.62.87.72 that I bought from DigitalOcean.
The result of the above configuration is that, the two URLs and 178.62.87.72 all lead to the same page of addbba.com.
If I delete the /etc/nginx/sites-enabled/addbba.com and leave only /etc/nginx/sites-enabled/matrixandcompany.com, the two URLs and 178.62.87.72 all lead to the same page of matrixandcompany.com.
So it seems that the URL is not well parsed and does not make any difference. Did I set something wrong in GoDaddy (maybe DNS?), or in nginx?
Thank you
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×