# How to Redirect a Subdomain to an External App

**URL:** <https://answers.netlify.com/t/how-to-redirect-a-subdomain-to-an-external-app/16001>\
**Category:** Support\
**Tags:** redirects, gatsby\
**Created:** [June 1, 2020, 3:46pm UTC](https://answers.netlify.com/t/how-to-redirect-a-subdomain-to-an-external-app/16001 "2020-06-01T15:46:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xoron](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/xoron/32/11619_2.png) [@xoron](https://answers.netlify.com/u/xoron)\
**Post date:** [June 1, 2020, 3:46pm UTC](https://answers.netlify.com/t/how-to-redirect-a-subdomain-to-an-external-app/16001/1 "2020-06-01T15:46:50Z")

</div>

i have a blog hosted on netlify pretty simple to setup… i have set it so that my DNS is managed by netlify.

i can create subdomain from the netlify control panel, but i dont know how to set it up so that a subdomain can point to a separate app (for example: hosted by aws)

currently when i create a subdomain ([test.my-blog.com](http://test.my-blog.com)), it simply points to the main site ([my-blog.com](http://my-blog.com)), which is the same thing as not having a subdomain.

i am looking at the documentation and it seems unclear to me so it would be helpful if someone can point me in the right direction or to an example similar to what i am describing.

---

<div class="post-metadata">

**Author:** ![perry](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/perry/32/16_2.png) [@perry](https://answers.netlify.com/u/perry)\
**Post date:** [June 1, 2020, 9:48pm UTC](https://answers.netlify.com/t/how-to-redirect-a-subdomain-to-an-external-app/16001/2 "2020-06-01T21:48:15Z")

</div>

hi xoron,

i think what you need is a redirect:

> **[Redirects and rewrites](https://docs.netlify.com/routing/redirects/)**
>
> Manage traffic to your site by defining redirect or rewrite rules in a \_redirects file or a netlify.toml file.

---

<div class="post-metadata">

**Author:** ![xoron](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/xoron/32/11619_2.png) [@xoron](https://answers.netlify.com/u/xoron)\
**Post date:** [June 3, 2020, 7:52am UTC](https://answers.netlify.com/t/how-to-redirect-a-subdomain-to-an-external-app/16001/3 "2020-06-03T07:52:38Z")

</div>

thanks for the reply.

looking at the documentation in the link provided i created 2 new files described as the following:

`_redirects`:

```auto
/testing-redirect https://www.petsofnetlify.com
https://pets2.my-blog.com https://www.petsofnetlify.com

```

i think this file is not working or has something not configured correctly. i have placed the file in the root directory of the project. none of the redirects work at all.

`https://pets2.my-blog.com` display the content of what is on `https://my-blog.com`. the same as not having a subdomain.

`netlify.toml`:

```auto
[[redirects]]
  from = "/pets"
  to = "https://www.petsofnetlify.com"
  status = 200
  force = true # COMMENT: ensure that we always redirect
  headers = {X-From = "Netlify"}
  signed = "API_SIGNATURE_TOKEN"

[[redirects]]
  from = "https://pets.my-blog.com"
  to = "https://www.petsofnetlify.com"
  status = 200
  force = true # COMMENT: ensure that we always redirect
  headers = {X-From = "Netlify"}
  signed = "API_SIGNATURE_TOKEN"

```

this file is working. so when i go to `https://pets.my-blog.com` i am redirected to `https://www.petsofnetlify.com`. (and the same for `my.blog.com/pets`).

but the behavior i am seeing is that the url is changed to: `https://www.petsofnetlify.com`… in the documentation [here](https://docs.netlify.com/routing/redirects/rewrites-proxies/#limitations), it says “For security reasons, rewrites between Netlify sites belonging to different teams are not allowed.”… so i tried to change this to another url (assumming `https://www.petsofnetlify.com` is hosted on netlify).

so i made the change the `netlify.toml` file and now it is working as expected. (not: to also include the url path into the proxy i added `/*` and `/:splat` as further explaining [here](https://docs.netlify.com/routing/redirects/rewrites-proxies/#proxy-to-another-service))

```auto
...

[[redirects]]
 from = "https://pets.my-blog.com/*"
 to = "https://my-aws-app.com/:splat"
 status = 200
 force = true # COMMENT: ensure that we always redirect
 headers = {X-From = "Netlify"}
 signed = "API_SIGNATURE_TOKEN"

```

i hope this helps anyone else having a similar issue.

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [June 8, 2020, 8:07am UTC](https://answers.netlify.com/t/how-to-redirect-a-subdomain-to-an-external-app/16001/4 "2020-06-08T08:07:20Z")

</div>

Thanks for sharing this detailed write-up of what worked for you! Post like these likely will help someone searching for their own solution and I’m sure these future visitors will appreciate the detail you provided in your answers.

Thanks again for this follow-up, @xoron.
