Redirect one domain to a subfolder inside another domain


I have and

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

Ideally all these permutations

Redirect the user to a subfolder inside of at

Please let me know

  1. What DNS records I would need for, and

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

Thank you!

Submit an answer

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!

Sign In or Sign Up to Answer

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.

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 syntax:

server {
  rewrite ^$request_uri? permanent;
or on any version 0.9.1 or higher:

server {
  return 301$request_uri;

Regards. KDSys

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.