Rewrite Conditions allowing specific domains, redirecting others with 301

Hi there,

I would like to know how I can allow only certains domains to access my files, while redirect others with a 301, or angry man maybe :wink:.

Today I’m redirecting all users trying to access my /fonts of my “font server” (yannglt-type.netlify.com) folder with a 301, thanks to the netlify.toml file. But I need my main site (https://yannglt.com) to access the font files.

Do you have any idea ?
Rewrite Conditions seems to be a good one but I didn’t find anything in the docs that might help me…

hmm, have you looked at out role based redirects?

https://docs.netlify.com/visitor-access/role-based-access-control/#create-users-and-set-roles

I’m not sure this is exactly what you want, but wanted to suggest it before we keep thinking.

Yeap, but can’t find any options that can satisfy what I’m looking for…

i just came across this old thread, which might be applicable to you:

1 Like

Thanks, I’m diving into this thread right now :wink:

Argh, nothing relative to exclude all domains except mines here… but thanks

Things are now fixed!
As you may see now on my website, things are now fixed! Hourra!

It was a bit complicated but here’s what I did, with developer friends of mine, using AWS buckets:

  • Create a bucket with my fonts files at the root (no “fonts” directory)
  • Allow public access for this bucket (private by default with AWS)
  • Change the bucket policy to only my desired domains
  • Add a CORS configuration for my bucket so Firefox and Chrome can call my font files (Safari seems to allow cross-origins resource sharing more easily…)

And voilà! Thank you anyway for your help.

awesome! thanks for sharing your solution! I bet someone else will find that super helpful!