Redirect rule in netlify.toml format

Sorry @morganfeeney, I think I misunderstood the original request!

[[redirects]]
  from = "/blackpool-hotels-with-parking/blackpool-(beach)"
  to = "/blackpool-hotels-with-parking/blackpool-(beach)-:id"
  status = 301
  query = {id = ":id"}

That will redirect /blackpool-hotels-with-parking/blackpool-(beach)?id=demo to /blackpool-hotels-with-parking/blackpool-(beach)-demo?id=demo.

Head’s up – we automatically pass through the query string parameter from the ‘from’ path to the new (‘to’) path.

If you don’t want ?id=demo in the new (‘to’) path, you can update your rule with a alternate, dummy query string parameter… which actually comes in handy, for knowing if somebody followed the redirect or browsed directly to the new (‘to’) path.

  to = "/blackpool-hotels-with-parking/blackpool-(beach)-:id?redir"
2 Likes