Subdomain redirect appears in deployed netlify.toml but doesn't work

Hello,

As per the topic I’ve used a netlify.toml to create a domain redirect on my site https://publicmap.netlify.app/ / https://publicmap.org

[[redirects]]
from = "https://events.publicmap.org"
to = "https://www.eventbrite.com/o/public-map-platform-85825239473"
status = 301
force = true

I followed this guide to set up a vanity URL to an external site.

I use a third party registrar and as per the guide I have a CNAME record set up for the subdomain.


I have added events.publicmap.org to my domain aliases on Netlify, and I have created my redirect in the netlify.toml file which is getting deployed properly along with the other internal redirects that Nextjs uses for image handling.

[images]
remote_images = [
  "^(?:https:\\/\\/cdn\\.sanity\\.io(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)|$))$"
]

[[redirects]]
from = "https://events.publicmap.org"
to = "https://www.eventbrite.com/o/public-map-platform-85825239473"
status = 301
force = true

[[redirects]]
from = "/_next/image"
to = "/.netlify/images?url=:url&w=:width&q=:quality"
status = 200

  [redirects.query]
  url = ":url"
  w = ":width"
  q = ":quality"

[[redirects]]
from = "/_ipx/*"
to = "/.netlify/images?url=:url&w=:width&q=:quality"
status = 200

  [redirects.query]
  url = ":url"
  w = ":width"
  q = ":quality"

[context]

  [context.production]

    [context.production.images]
    remote_images = [
      "^(?:https:\\/\\/cdn\\.sanity\\.io(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)|$))$"
    ]

  [context.main]

    [context.main.images]
    remote_images = [
      "^(?:https:\\/\\/cdn\\.sanity\\.io(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)|$))$"
    ]

It links to the main Netlify site so that part is working, but the actual redirect is not. I’m at a loss on what I’m missing. Please help!

Thanks
Roo

You seem to have an Edge Function (likely your middleware) causing the issue. You should try checking for the domain in the middleware and redirect from there.

1 Like

Thank you - that got me unstuck!