Add redirects for Vue SPA with subdomains hosted on Netlify

I have a vue SPA app hosted on netlify. I got it working using this redirect:

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

But now I want to make another redirect. If it receives a request from app.domain.com.br then it must redirect to domain.com.br/app/. To achieve that i tried to use this redirect:

[[redirects]]
  from = "https://app.domain.com.br/*"
  to = "https://prod.domain.com.br/app/:splat"
  status = 301

I dont know how to use these two redirects together.

OBS: I want that if someone access by app.domain.com.br, it should no show domain.com.br/app but continue showing app.domain.com.br/whatever

Now my netlify.toml is this:

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

[[redirects]]
  from = "https://app.domain.com.br/*"
  to = "https://domain.com.br/app/:splat"
  status = 301

[[redirects]]
  from = "http://app.domain.com.br/*"
  to = "https://domain.com.br/app/:splat"
  status = 301
1 Like

Hi @hubertokf ! I think we worked through this in the helpdesk that you’d need the redirects to be 200 if you want the URL to remain the same.

Further, you’d need the /* SPA redirect to be AFTER the domain name specific redirects, which should always go first.

1 Like