Access subdomain as placeholder/parameter in redirect

We are moving our site from a self-hosted server to Netlify. Our site can be visited by quite a few subdomains, and we have some rewrite rules in Nginx that redirect based on the subdomain, e.g.: redirects to redirects to

In nginx, it’s pretty trivial to access the subdomain/host name and use that as a parameter in the redirect, but I couldn’t see any mention of this in the _redirects docs. I understand that I could write a domain-specific rule for each subdomain, but we’re actually handling a lot of subdomains, and I’d prefer to have a wildcard approach so that we didn’t have to push a change to the _redirects file every time we added or removed a domain. Is such a thing possible?

Hi, @kid_for_today, you are correct that this would be a feature request and isn’t possible at this time.

I looked for an existing feature request to match this and I don’t find one. I’d be happy to file one. I do want to understand the functionality in Nginx you would like to see our redirects duplicate before I file it though.

I came across this stack overflow post:

Does that accurately describe the functionality you are using with Nginx and want to see possible with our redirects? If not, would you please post a link here to relevant documentation or examples so I’m sure I “getting the idea”.

Or if you just want to post an example of how you would want it to work with our service, that would be fine as well. I just want to be sure we don’t build a feature that misses the point and doesn’t do what is required.

Hi @luke

Sorry for the delayed reply. The nginx redirect stack overflow link is broadly correct, although in this case we don’t need the broad regex support that nginx providers – any way to extract the subdomain and add it elsewhere in the url would be fine. That said, we would probably need a way capture more than simply the subdomain, because we also capture everything at the end of the url and redirect that as well, so the final form would need to be something like: redirects to

Which I suppose would require two changes to the netlify redirects as they exist now:

  1. the ability to have more than one capture group
  2. the ability to capture the subdomain from the URL

Hope this clarifies the issue for you, and thank you for following up.