Home
Support Forums

Proxies and paths

I have some questions around proxying to a service. Here’s the scenario:

I have https://website.com that has it’s own repo.

I also have website.com/directory that has it’s own repo.

I also have website.com/directory/app that has a different repo.

I’m building website.com on Netlify, but need to point to the other two repos and have them resolve to websitecom/directory and websitecom/directory/app respectively. However, in my tests, I do something like:

from = “/directory/*”
to = “some-aws-bucket.s3com/directory/:splat”
status = 200
force = true

from = “/directory/app/*”
to = “some-other-aws-bucket.s3com/directory/app/:splat”
status = 200
force = true

Obviously this can’t work, because https://website.com/directory/app gets snatched up by the /directory/* rule. But, if I change the rule and remove the star, then nothing else in the directory will work either. As a side note, the images don’t resolve because they’re /images, not /directory/images.

Is there another way to accomplish what I’m trying to do?

UPDATE:
For novices, it may not be apparent that the order of the rules makes a difference. Switching the rules seems to have made it work for now, but I’m still running into the same problem of images not resolving correctly.

I don’t know that I want to go and change the source of all my images unless it’s unavoidable.

Correct @dhill as mentioned in Redirects and rewrites > Rule processing order

The interesting thing is that Netlify “should” be adding the trailing slash according to their docs. If the “Pretty URLs” is enabled, which it is, it should be adding the trailing slash for consistency - regardless of the endpoint being a file or directory. Alas, it is not adding it.

Is there another way to write the rule in order for Netlify to add the trailing slash? I think I’ve tried a dozen different ways and still cannot figure out why it won’t add the slash or at least point the directory that has the slash in the rule.

It seems Netlify is doing the redirect on the subpages, but not the main page.

Pretty URLs is not meant to add redirects to serve with trailing slash, more on that here:

About the redirects, the configuration that you have with the correct order should work correctly.