Miki9
By:
Miki9

Why my domain xyz.com is redirect to abc.com?

July 17, 2016 1.2k views
DNS Nginx PHP WordPress Ubuntu 16.04

I have hosted two wordpress websites on single droplet and trying to host another one which is xyz.com but the problem is that when I open xyz.com it redirects to my default server domain name abc.com please help me in this, I am stuck from 2 days.
DNS setting:
A record @ 198.xxx.xxx.xxx
CNAME:www xyz.com.
CNAME:* xyz.com.
ns:ns1.digitalocean.com.
ns:ns2.digitalocean.com.
ns:ns2.digitalocean.com.

Server Block:

server {
listen 80;
listen [::]:80;

root /var/www/xyz.com/html;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name xyz.com www.xyz.com;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.php?$args;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;   
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}   

}

thanks

2 comments
  • Can you please post the server block to abc.com.
    I see that you have two Cname records, where are they pointed to?

  • If you get a chance to post your server block for the second site that may reveal the issue - please update when you're able.

2 Answers

This question was answered by @MDS:

Can you please post the server block to abc.com.
I see that you have two Cname records, where are they pointed to?

View the original comment

Hi..We are also facing similar issue..Hosted two sites, the second one is always getting redirected to the first one..The details follows:

  1. A record for both domains: @ IP Number
  2. CNAME for both domains: *domain name.
  3. Server block for first domain:
    server {
    listen 80 defaultserver;
    listen [::]:80 default
    server ipv6only=on;

    root /var/www/first-site.in/html;
    index index.php index.html index.htm;

    Make site accessible from http://localhost/

    server_name first-site.in www.first-site.in;

  4. Server block for second domain:
    server {
    listen 80;
    listen [::]:80;

    root /var/www/second-site.net/html;
    index index.php index.html index.htm;

    Make site accessible from http://localhost/

    server_name second-site.net www.second-site.net;

Please tell us, how this issue can be solved..Thanks and Regards..

Have another answer? Share your knowledge.