# Prevent Google from indexing netlify URL

**URL:** <https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765>\
**Category:** Support\
**Tags:** netlify-newbie\
**Created:** [July 13, 2020, 5:20am UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765 "2020-07-13T05:20:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![flynet](https://avatars.discourse-cdn.com/v4/letter/f/9e8a1a/32.png) [@flynet](https://answers.netlify.com/u/flynet)\
**Post date:** [July 13, 2020, 5:20am UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765/1 "2020-07-13T05:20:21Z")

</div>

After connecting a custom domain, how do we prevent Google from indexing the netlify URL (example.netlify.app)?  
I’m using Netlify DNS.

Can someone confirm these are the steps?

**Step 1**. Save a plain text file called `_redirects` in my root directory. (Note: my project is just an `index.html` file in my root directory. Not using a build command or static site generator).  
**Step 2**. Inside of the `_redirects` file write:  
`https://example.netlify.app https://example.com 301`

Is that it? Do I need to write the `http` and `www` versions of these lines too?

Is the `netlify.toml` file required too?

Thanks

---

<div class="post-metadata">

**Author:** ![Dennis](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/dennis/32/34_2.png) [@Dennis](https://answers.netlify.com/u/Dennis)\
**Post date:** [July 17, 2020, 5:46pm UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765/2 "2020-07-17T17:46:46Z")

</div>

Hi @flynet,

You could try using a custom headers rule in a \_headers file, like this:

```auto
https://example.netlify.app/*
   X-Robots-Tag: noindex

```

This will tell google not to index that url at all. Let me know if that works for you.

---

<div class="post-metadata">

**Author:** ![flynet](https://avatars.discourse-cdn.com/v4/letter/f/9e8a1a/32.png) [@flynet](https://answers.netlify.com/u/flynet)\
**Post date:** [July 17, 2020, 10:06pm UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765/3 "2020-07-17T22:06:53Z")

</div>

I created a `_redirects` file based on the solution described [here](https://answers.netlify.com/t/netlify-app-and-netlify-com-subdomains-are-showing-in-google-search-results/13919/10). The file says:

```
https://example.netlify.app https://example.com 301!
http://example.netlify.app https://example.com 301!

```

Do I also need to add the custom headers rule? According to [this](https://support.google.com/webmasters/answer/93633?hl=en) Google article: " **If you need to change the URL of a page as it is shown in search engine results** , we recommend that you use a server-side 301 redirect. "

Please clarify if the current setup is enough or if the `_headers` file is required too.

Thank you!

---

<div class="post-metadata">

**Author:** ![flynet](https://avatars.discourse-cdn.com/v4/letter/f/9e8a1a/32.png) [@flynet](https://answers.netlify.com/u/flynet)\
**Post date:** [July 17, 2020, 10:08pm UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765/4 "2020-07-17T22:08:24Z")

</div>

I followed the solution [here](https://answers.netlify.com/t/netlify-app-and-netlify-com-subdomains-are-showing-in-google-search-results/13919/10).

Do I also need the `_headers` file? [This](https://support.google.com/webmasters/answer/93633?hl=en) Google article suggests that 301 is enough to change the URL in search results.

Please advise. Thank you.

---

<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:** [July 20, 2020, 4:50am UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765/5 "2020-07-20T04:50:44Z")

</div>

Hi, @flynet, the `301!` rules will force all traffic to the custom domain. This alone is enough to prevent Google from indexing those pages.

However, if you have a site without a custom domain, the \_headers rules are another way to prevent indexing. This can be helpful when you have a demo/testing site without a custom domain and you don’t want it indexed.

There is a third method as well. The “robots meta tag”:

> **[Robots Meta Tags Specifications | Google Search Central  | ...](https://developers.google.com/search/docs/crawling-indexing/robots-meta-tag)**
>
> Learn how to add robots meta tags and read how page and text-level settings can be used to adjust how Google presents your content in search results.

To summarize, the `301!` rules can only be used with custom domains. The X-Robots-Tag HTTP header and robots meta tag can be used on any sites, custom domain or not.

---

<div class="post-metadata">

**Author:** ![bondbipu](https://avatars.discourse-cdn.com/v4/letter/b/65b543/32.png) [@bondbipu](https://answers.netlify.com/u/bondbipu)\
**Post date:** [March 3, 2022, 1:08pm UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765/6 "2022-03-03T13:08:19Z")

</div>

@Dennis

Sorry for hijacking this. But I have a question.

I am using Hugo. How can I put this (the \_herders file) in my Hugo site?

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [March 6, 2022, 2:08pm UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765/7 "2022-03-06T14:08:38Z")

</div>

By creating that file in the `public` folder.

---

<div class="post-metadata">

**Author:** ![victor.navarro](https://avatars.discourse-cdn.com/v4/letter/v/ce73a5/32.png) [@victor.navarro](https://answers.netlify.com/u/victor.navarro)\
**Post date:** [February 13, 2025, 11:59am UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765/8 "2025-02-13T11:59:00Z")

</div>

Hey, sorry for reviving this conversation, but I have a question about this:  
If I have a custom domain connected in Netlify, does Netlify automatically use headers in the \*\*\*.netlify.app doimain to tell Google to not index it? I’m a bit worried that having duplicate content (since it’s the same website on 2 different domains) will hurt SEO.

Thanks!

---

<div class="post-metadata">

**Author:** ![hrishikesh](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hrishikesh/32/74607_2.png) [@hrishikesh](https://answers.netlify.com/u/hrishikesh)\
**Post date:** [February 15, 2025, 12:47pm UTC](https://answers.netlify.com/t/prevent-google-from-indexing-netlify-url/18765/9 "2025-02-15T12:47:28Z")

</div>

No, we don’t. You can setup 301 redirects to redirect to the custom domain.
