Redirect proxied website

We have two sites on Netlify, one that proxies the other, but I want them to always use the proxied path.

Currently there is a redirect like the following on site-a.com.

# _redirects for site-a.com

/othersite  site-b.com/:splat 200

This works fine, but someone can still go to site-b.com and browser around as such. How can I add a redirect to site-b.com that makes it so it takes you to site-a.com/othersite without causing an infinite redirect loop?

Hi @jclusso

It is entirely possible to redirect site-b.com to site-a.com/siteb using a domain-level redirect. However, having this in place while proxying as you are causes the proxy to fail as the proxied path is also the endpoint of another redirect.

I know this and that is the problem I’m trying to solve… Are you saying it’s not possible to solve?

I don’t believe there is any officially supported workaround for this.

Hi @jclusso,

I believe this has been responded to in the helpdesk.

For others coming to this, the “easier” solution might be to use JavaScript to check location.host and redirect using location.href.

1 Like