PrashantB
PrashantB

Reputation: 155

Nginx redirect domain to subdomain url with persist url

We have a ruby application serving through passenger+nginx on url like abc.xyz.com. Now we want to point/redirect xyz.com to abc.xyz.com/client/page. Below is tried code

server {
    server_name xyz.com;
    location  / {
         return 301 $scheme://abc.xyz.com/client/page;
    }
}

But in browser URL it shows abc.xyz.com/client/page. We want the xyz.com.

Upvotes: 0

Views: 947

Answers (1)

PrashantB
PrashantB

Reputation: 155

Got the solution and working fine on single Nginx server:

Added server name entry as below to the existing,

server_name abc.xyz.com xyz.com;

in server block added below

    if ($host = xyz.com)
    {
rewrite ^/$ $scheme://$host/client/page/;
}

But now big work remaining, I need to change this config according to proxy_pass.

Upvotes: 1

Related Questions