Home
Support Forums

Redirect reverse-proxy for 301 origin response

Is it possible to configure the Netlify reverse proxy to overwrite a 301 response from origin ?

I know that it’s a bit crazy… but here we are.

I have this redirect rule.

[[redirects]]
  from = "/documentation/*"
  to = "https://yeovil.sftpplus.com/documentation/:splat"
  status = 200
  force = true

The issue is that an URL like Documentation Start Page | SFTPPlus Documentation | Server and Client secure file transfer software for SFTP, FTP, FTPS, and HTTPS. Enterprise data MFT across Windows, Linux, macOS, and containers. is configured on the origin server to redirect to Documentation Start Page | SFTPPlus Documentation | Server and Client secure file transfer software for SFTP, FTP, FTPS, and HTTPS. Enterprise data MFT across Windows, Linux, macOS, and containers.

The netlify reverse proxy works … but end up with users getting outside of the main domain.

I am trying to deploy a single domain - multi repo site.

The main site is in one repo and the documentation (with all versions) in another repo

For now I am just testing a migration…so the documentation is still hosted on the my VPS server.

For example I have these URLs

I am expecting both of them to return the same content.

The actual result is that the second URL without a trailing slash ends up with a redirection to the origin server and not with a reverse proxy.

Thanks!

Hi @adiroiban,

That’s actually expected behaviour. Netlify’s rewrites will return the response headers sent by the destination content. In your case, the response is returning 301 with location header:

Thus, it’s redirecting accordingly.

I think you could use placeholders to always rewrite to the URL with the trailing slash. For example like this:

[[redirects]]
  from = "/documentation/:page"
  to = "https://yeovil.sftpplus.com/documentation/:page/"
  status = 200
  force = true

Thanks a lot.

Well, there are hundred of pages… but I am not sure how :page can be used.

I could not find it documented here Redirect options | Netlify Docs

The plan is to host the documentation in a separate Netlify repo, with each version of the documentation deployed in a separate branch.

There is Documentation Start Page | SFTPPlus Documentation | Server and Client secure file transfer software for SFTP, FTP, FTPS, and HTTPS. Enterprise data MFT across Windows, Linux, macOS, and containers. and Documentation Start Page | SFTPPlus Documentation | Server and Client secure file transfer software for SFTP, FTP, FTPS, and HTTPS. Enterprise data MFT across Windows, Linux, macOS, and containers. and so on

I don’t want visitor to be redirected to something like https://v4.13.0--sftpplus-docs.netlify.app/

That’s a placeholder, just like * is for match all. :page in the above example would match everything till the next /. For example, in this URL: www.foo.com/bar/, :page would match bar.

It’s documented in the placeholder section in the link you posted.