Deploy netlify.toml file only?

Hey support team,

I’m using branch deploys AND branch subdomains to setup some subdomains for my site and I basically need the main domain to always redirect to my subdomain, like so:

https://domain.comhttps://app.domain.com

where the branches are associated as follows

masterhttps://domain.com
apphttps://app.domain.com

Now, I was able to achieve this behavior using 2 different redirects (between the branches), but I was wondering if it’s possible to delete everything but the netlify.toml from the master branch and have some sort of dummy build command not to build the entire CRA app when pushing anything to master? Granted nobody will push anything to master, but I sort of wanted to cleanup that branch to be honest, since it doesn’t need to have the entire app code.

Hi @niceshadowraze

You’ll need an index.html as well.

Simplest thing is to have an index.html with

<!doctype html><html lang="en"><meta charset=utf-8><title>shortest html5</title>

and a _redirects file with

/*      https://new.domain.com    301!

which will send all traffic to the new domain (you could use a netlify.toml too.)

Hey, thank you for your reply. So can I literally delete everything else in that branch and just leave the index.html and netlify.toml (or _redirects) file in the root dir?

Yes you could (remembering to remove the build command too.)

Alternatively, you could stop deploying the main/master branch altogether, and add domain.com as an alias to app.domain.com and have it redirect.

This assumes you are not using the branch deploy feature though, and are deploying branches to separate Netlify sites.

Alright, simple enough. Thank you!