Home
Support Forums

Proxy/forward entire subdirectory EXCEPT for one sub-subdirectory

Hello all! Another redirect question that I can’t solve after testing.

I have the following in my netlify.toml file:

[[redirects]]
  from = "https://www-staging.getvero.com/resources/*"
  to = "https://REDACTED.com/resources/:splat"
  status = 200
  headers = {X-Vero-Netlify = "true", X-Vero-Proxied = "true"}

It works very nicely. However, we’re rebuilding the assets at Free HTML & MJML templates - Vero and are now hosting that page + some sub-pages, such as Osaka - Vero on Netlify.

I’m hoping to find a way that I can NOT proxy requests for https://www-staging.getvero.com/resources/html-email-templates/* BUT still proxy all other requests to https://www-staging.getvero.com/resources/*.

Is there some way I can do this? I haven’t been able to figure out an approach that works so hoping someone has tried this before!

Thank you.

To “exclude” you can create a rule that shadows the files to their existing location, prior to the one that proxies the requests externally.

Example Origin
https://quirky-brahmagupta-437e84.netlify.app
https://quirky-brahmagupta-437e84.netlify.app/resources/html-email-templates/
https://quirky-brahmagupta-437e84.netlify.app/resources/html-email-templates/osaka/

Example External Resources
https://focused-ride-1a4886.netlify.app/resources/a
https://focused-ride-1a4886.netlify.app/resources/b
https://focused-ride-1a4886.netlify.app/resources/external-subfolder/c
https://focused-ride-1a4886.netlify.app/resources/external-subfolder/d

This was achieved with the following rules in the netlify.toml:

[[redirects]]
  from = "/resources/html-email-templates/*"
  to = "/resources/html-email-templates/:splat"
  status = 200

[[redirects]]
  from = "/resources/*"
  to = "https://focused-ride-1a4886.netlify.app/resources/:splat"
  status = 200
  headers = {X-Vero-Netlify = "true", X-Vero-Proxied = "true"}
1 Like

Thanks for this, fantastic.

This is what I’ve ended up with — and it works nicely!

The community does it again :).

[[redirects]]
  from = "/resources/html-email-templates/*"
  to = "/resources/html-email-templates/:splat"
  status = 200
  force = true
  
[[redirects]]
  from = "https://www-staging.getvero.com/resources/*"
  to = "https://REDACTED/resources/:splat"
  status = 200
  headers = {X-Vero-Netlify = "true", X-Vero-Proxied = "true"}
3 Likes