Possible to create equivelant nginx redirect with functions?

Hey all,

I am taking a look at functions and redirects but running into multiple issues.

location = /.well-known/host-meta {
return 301 https://social.example.com$request_uri;
}

If I understand functions correctly, I would have been able to use them but it either doesn’t like the - in the directory or possibly the fact that it is a dot directory. Actually even a hello-world example fails if I change the name of the parent to try to match the URL scheme of .well-known/host-meta

Not surprised to hear about multiple issues for that particular path!

  1. for paths starting with /.anything, you’ll need instead to create redirects on your site to first redirect them to paths without leading dots before we can serve them. So, you’d do something like /.well-known/* /.netlify/functions/myfunction/:splat 200! to move the traffic over to a path we can serve (note that /.netlify is a special path that we can host content under - and do - but you cannot).

  2. of course we don’t use that syntax for our redirects (what we use is specific to Netlify and is documented here: Redirects and rewrites | Netlify Docs)

  3. then, redirects are odd to do in functions - that’s slow! They’d need to run just to return a 301? Why not use an Edge Function instead? Rewrite with Edge Functions | Edge Functions on Netlify