1

I have the following two domains:

  • myVeryLongSiteDomain.com
  • mVeryShortURL.co

I need the following short URLs:

  • mVeryShortURL.com/123456789
  • mVeryShortURL.com/a-DSa131_

To redirect to the long site domain like so:

  • myVeryLongSiteDomain.com/feedback/123456789
  • myVeryLongSiteDomain.com/feedback/a-DSa131_

Note, how the /feedback/ url path is added

How can I make this work? Is it possible with just DNS? Do I need to host a app just for the ShortURL domain that does this redirection? FYI, my longsitedomain is a react app hosted on heroku.

What is the cleanest, right way, to make this happen?

AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012

1 Answers1

1

Sadly, no, the redirection is not possible using only DNS. DNS can only gives you an IP-Address which your browser will contact.

You will need to host an app (extra server, virtual host, heroku app, ...) which does the redirection. Since it doesn't do much, this can be really lightweight. Since you are using 2 different apps, the framework you are using for your main app doesn't matter at all.

One way of doing it is to use a small php wrapper script which does the redirection and using mod_rewrite to make your apache to route all requests to your main php file. The mod_rewrite part is explained here

Another way comes without any scripting and only a webserver:

If your main site uses HTTPS, which is very likely, since you are using Heroku, your redirection site should do the same. Should domains which only make redirects (aka tiny urls) be encrypted (https)?

rollstuhlfahrer
  • 3,988
  • 9
  • 25
  • 38