Report this

What is the reason for this report?

Redirect one domain to a subfolder inside another domain

Posted on October 22, 2019

Hi,

I have product.com and company.com

I would love to figure out how to tell both the DNS and Nginx to redirect product.com to a folder inside the company.com domain.

Ideally all these permutations

http://product.com
https://product.com
http://www.product.com
https://www.product.com

Redirect the user to a subfolder inside of company.com at

https://company.com/product

Please let me know

  1. What DNS records I would need for product.com, and compnay.com

  2. What Nginx rule(s) I would need for product.com, and compnay.com

Thank you!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.
0

Accepted Answer

Hi @digitaldev,

Using DNS for a HTTP redirection is not possible with just DNS. There are companies providing DNS forwarding though.

As for the Nginx rules, now that’s possible.

You can server_name which supports suffix matches using .mydomain.com syntax:

server {
  server_name .mydomain.com;
  rewrite ^ http://www.adifferentdomain.com$request_uri? permanent;
}
or on any version 0.9.1 or higher:

server {
  server_name .mydomain.com;
  return 301 http://www.adifferentdomain.com$request_uri;
}

Regards. KDSys

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.