I want to redirect from this url...
https://example.com/page?id=abc
To this:
https://example.com/page/abc
Netlify allows you to redirects based on query params, hooray! Here's an example from the docs:
/store id=:id /blog/:id 301
# /store?id=my-blog-post to /blog/my-blog-post with a 301 redirect
So, this would just work, right?
/page id=:id /page/:id 301
No. No it wouldn't.
It turns out 'shadowing' is a thing. In short, Netlify won't accept the rule if there's already a static asset at the target address.
# working
/page id=:id /page/:id 301!
This baffles me a little bit, because supposedly, 301
is the default rule and these all works fine:
# /b is a static page
/a /b
Also, seeing Netlify being mostly known as a static site host, I'd expect redirecting into existing static pages would be the majority of the cases.
Anyway, I wasted 30' on this... should I have just learn to read the docs better? Maybe. At least I hope this helped other fellows who can't read docs.
Top comments (0)