1 App Routing Multiple Domains to Sub Directories

I have 1 app/site hosted on Netlify. I have multiple domains pointed to the 1 site. I’m trying to find a way to route different domains to different paths on the site.


I would like domain1.com to go to front page of site
I would like domain2.com to go to a subdirectory such as domain2.com/folder1 (but show as domain2.com with no sub folder in URL path)

I’ve tried all the examples in both the redirects file and the .toml file but can’t seem to get it to work. Basically, i need the site to look at incoming URL and direct to different conten much the way you could setup a webserver to point a domain to a specific folder.

Any advise appreciated.

Hello @netlishan , thanks for posting your question and welcome to the Netlify support forum

I need to understand your use case before I can assist you. If I understand you correctly you want to configure redirects based on my explanation below

  1. domain_1.com and domain_2.com both point to your single Netlify site (example: your_site.netlify.app)
  2. You want domain_1.com to point to the homepage of your_site.netlify.app
  3. You want domain_2.com to point your_site.netlify.app/folder1 but still show as domain_2.com.

If the above is the case first of all make sure both domains are linked to your Netlify site your_site.netlify.app and then set domain_1.com as your primary domain and then configure your netlify.toml file below. Replace https://domain_2.com with your domain.

    from = "https://domain_2.com"
    to = "https://domain_2.com/folder1"
    status = 200
    force = true
  • 200: OK code. Redirects with this status code will change the server response without changing the URL in the browser address bar. This is used for rewrites and proxying.

Correct me if the above scenario is what you want to achieve. Let me know if it works.