0

We're moving a website from www.xdomain.com to www.ydomain.com

It's primarily a forum, with many topics.

Therefore it would be common for someone to bookmark e.g.

www.xdomain.com/forum/board/topic?blah or something.

Our goal is to have a seamless transfer from one domain to the other (currently we have both domains pointing to the same folder in hosting), but we would prefer this to happen:

www.xdomain.com/forum/board/topic?blah redirects to www.ydomain.com/forum/board/topic?blah

i.e. the ONLY changes is BEFORE the .com - all the subfolders are exactly the same and compatiable.

Is this possible to do? If so, how could I do it in nginx? The main reason is for bookmarks AND to force the use of our new domain.

Thanks.

Kevin
  • 979
  • 4
  • 10
  • 22
  • It's important to note that you must keep `xdomain.com` registered and pointing to your server for any sort of nginx-based redirection to work. – SeinopSys Nov 06 '16 at 22:25

1 Answers1

1

Use two server blocks, one for each domain. Then set a permanent redirect.

server {
    server_name www.xdomain.com;
    return 301 $scheme://www.ydomain.com$request_uri;
}
server {
    server_name www.ydomain.com;
    ...
}

See this document for more.

Richard Smith
  • 45,711
  • 6
  • 82
  • 81