Hello, my domain “elite-earthworks.com” has been live for a few months but I noticed the other day the old subdomain “eliteearthworks.netlify.app” was also appearing in the search results. Is there a way I can remove the .netlify.app subdomain so it doesn’t show up on google? I’m assuming looking at my dns records that it’s related to the Netlify files that are currently in there?
Hi, @SovietBeatle. You can prevent this by making sure the site never uses the netlify.app
subdomain version of the site (eliteearthworks,netlify.app
) and always redirects to the custom domain version of the site.
This can be done using the Redirects feature:
There are two formats for redirect rules. They both results in identical rules internally but the formats before processing by the build system are different. So, these are two ways of writing the same rule below.
First, the _redirects
format as I prefer it (because it is more succinct and, therefore, clearer to me):
https://eliteearthworks.netlify.app/* https://elite-earthworks.com/:splat 301!
The same rule in netlify.toml
format would be:
[[redirects]]
from = "https://eliteearthworks.netlify.app/*"
to = "https://elite-earthworks.com/:splat"
status = 301
force = true
Whichever file is used, that file then needs to be moved to the publish directory of the site when the site’s build finished. If the file is in the publish directory, the post processing will process the file and create the redirect rules.
Once the rule exists, then eliteearthworks.netlify.app
will only redirect to elite-earthworks.com
and that will mean that eliteearthworks.netlify.app
will never be indexed again. After some time, the search engine results will be removed. You can expedite the removal by claiming the eliteearthworks.netlify.app
subdomain via Google’s Search Console and asking for the domain to be re-indexed immediately (and the re-indexing will result in only 301s removing all results).
Awesome! I like easy fixes. Thanks for the help!