# Redirect sub domain

**URL:** <https://answers.netlify.com/t/redirect-sub-domain/4553>\
**Category:** Support\
**Tags:** redirects, netlify-dns-https-ssl\
**Created:** [October 29, 2019, 6:59am UTC](https://answers.netlify.com/t/redirect-sub-domain/4553 "2019-10-29T06:59:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![spences10](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/spences10/32/2174_2.png) [@spences10](https://answers.netlify.com/u/spences10)\
**Post date:** [October 29, 2019, 6:59am UTC](https://answers.netlify.com/t/redirect-sub-domain/4553/1 "2019-10-29T06:59:23Z")

</div>

Hello! 👋

How do I redirect from `mysubdomain.mydomain.com` to `myotherdomain.com`?

I already have a `_redirects` file redirecting path slugs but I want to redirect this sub domain to a new domain now.

---

<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:** [October 30, 2019, 8:47am UTC](https://answers.netlify.com/t/redirect-sub-domain/4553/2 "2019-10-30T08:47:26Z")

</div>

Hi, @spences10, and welcome to our community site.

Two rules are recommended, one each for HTTP and HTTPS urls respectively. Using the examples you provided, the rules would look like this:

```plaintext
http://mysubdomain.mydomain.com/* https://myotherdomain.com/:splat 301!
https://mysubdomain.mydomain.com/* https://myotherdomain.com/:splat 301!

```

Both rules direct to HTTPS because I’m assuming both domains are at Netlify. We don’t support non-SSL HTTP connections - only HTTPS.

If the target site isn’t at Netlify, though, feel free to redirect HTTP to HTTP if you prefer. At Netlify though, the target URL should always be HTTPS.

The `301!` in the rule tell Netlify’s CDN to issue an HTTP redirect (a 301 status) which will change the URL in the address bar.

The `!` (in `301!`) means always redirect, even if the asset exists at the original URL (which is the most commonly used configuration). If the `!` is removed, the redirect won’t trigger if there if the URL is valid at the starting domain (which is probably not what you want).

Note, this will only work if starting domain (`mysubdomain.mydomain.com`) has a DNS configuration which directs this traffic to Netlify. Directing the domain to Netlify can be done with either [Netlify DNS](https://docs.netlify.com/domains-https/netlify-dns/) or [external DNS configuration](https://docs.netlify.com/domains-https/custom-domains/configure-external-dns/).

​Please let us know if there are other questions about this or the redirect above doesn’t work as expected.

---

<div class="post-metadata">

**Author:** ![spences10](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/spences10/32/2174_2.png) [@spences10](https://answers.netlify.com/u/spences10)\
**Post date:** [October 30, 2019, 12:16pm UTC](https://answers.netlify.com/t/redirect-sub-domain/4553/3 "2019-10-30T12:16:51Z")

</div>

Thanks @luke

I’ve added that to the project `_redirects` it’s not immediately redirecting so I’m presuming DNS magic needs to happen first.

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [October 31, 2019, 1:29am UTC](https://answers.netlify.com/t/redirect-sub-domain/4553/4 "2019-10-31T01:29:18Z")

</div>

If dns isn’t pointed to us then indeed that pattern won’t work. If it does get pointed to us and still doesn’t work, please do let us know your URL so we can take a closer look at your configuration.

---

<div class="post-metadata">

**Author:** ![spences10](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/spences10/32/2174_2.png) [@spences10](https://answers.netlify.com/u/spences10)\
**Post date:** [October 31, 2019, 6:15am UTC](https://answers.netlify.com/t/redirect-sub-domain/4553/5 "2019-10-31T06:15:47Z")

</div>

Hey @fool, so the domain is `ss10.dev` and the DNS is configured from Namecheap to Netlify.

I want to point the sub domain of `cheat-sheets.ss10.dev` to `cheatsheets.xyz` which is not currently on Netlify.

At the moment this is what my `_redirects` file looks like:

```auto
http://cheat-sheets.ss10.dev/* https://cheatsheets.xyz/:splat 301!
https://cheat-sheets.ss10.dev/* https://cheatsheets.xyz/:splat 301!

```

This doesn’t seem to do the thing right now though.

Thanks

---

<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:** [October 31, 2019, 6:47am UTC](https://answers.netlify.com/t/redirect-sub-domain/4553/6 "2019-10-31T06:47:31Z")

</div>

@spences10, I think we are closer to a solution! The DNS records to point to Netlify so that is not the root cause.

I found part of the issue here:

> **[Netlify App](https://app.netlify.com/sites/jovial-brown-7e7758/deploys/5db97e0c703af6da8c9c6a0c)**
>
> Start building the best web experiences in record time

Quoting that page:

> No redirect rules processed  
> This deploy did not include any redirect rules. Learn more about redirects.

I then used the download deploy button on that page to examine the deployed files. Please see the screenshot below for an example of where to find the button.

 ![download-deploy-button](https://global.discourse-cdn.com/netlify/original/2X/a/ae640b09c9c8bd86b8945000483f22870cda0799.png)

When I extract the zip file, I find no file named `_redirects` in it. Are you certain this file is being uploaded to Netlify? If not, would you please test to deploying again - making sure to include this file in the base directory of the uploaded files?

If this doesn’t resolve it or there are any questions, we’re happy to follow-up again so please let us know if this is the case.

---

<div class="post-metadata">

**Author:** ![spences10](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/spences10/32/2174_2.png) [@spences10](https://answers.netlify.com/u/spences10)\
**Post date:** [October 31, 2019, 1:11pm UTC](https://answers.netlify.com/t/redirect-sub-domain/4553/7 "2019-10-31T13:11:22Z")

</div>

Ok, maybe I should have paid attention to that before posting! 🙃

So, I built my site again, locally, and tried again and the `_redirects` doesn’t go into the build when building locally for some reason??

What I’m going to to is revert to the GitHub integration, push the file to GitHub and see if that does the trick.

---

<div class="post-metadata">

**Author:** ![spences10](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/spences10/32/2174_2.png) [@spences10](https://answers.netlify.com/u/spences10)\
**Post date:** [October 31, 2019, 1:34pm UTC](https://answers.netlify.com/t/redirect-sub-domain/4553/8 "2019-10-31T13:34:07Z")

</div>

So, although, for some reason even when connecting a GitHub repo the redirects file still wasn’t being shown in the deploy summary.

What I did was after building the site locally, chucked the `_redirects` file into the `public` folder then manually deployed that.

Added the sub domain to that and tried again, this time it appears to redirect but the URL doesn’t change is that the 301 splat thing?

---

<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:** [November 1, 2019, 7:04am UTC](https://answers.netlify.com/t/redirect-sub-domain/4553/9 "2019-11-01T07:04:40Z")

</div>

I get the 301 redirect when I test now:

```nohighlight
$ curl -sv https://cheat-sheets.ss10.dev/ 2>&1 | egrep "^<.*$"
< HTTP/2 301
< cache-control: public, max-age=0, must-revalidate
< content-length: 40
< content-type: text/plain; charset=utf-8
< date: Fri, 01 Nov 2019 07:02:35 GMT
< location: https://cheatsheets.xyz/
< age: 7
< server: Netlify
< x-nf-request-id: 73784824-9b29-43db-9c85-6f67788617bf-8775509
<

```

This does change the domain/URL in the address bar when tested with a web browser also.

Did you resolve this issue? If it still isn’t working when you test, would you please send the `x-nf-request-id` header for a page load which doesn’t work?
