Hi there. Having problems with a redirect. The syntax from our netlify.toml is:
[[redirects]]
from = "/"
query= {ll_ref_id = ":ll_ref_id"}
to = "/collections/library/?ll_ref_id=:ll_ref_id"
force = true
Expected behaviour:
It should allow the homepage to serve as normal unless there is a url parameter named ll_ref_id. Then should redirect with that parameter intact.
Eg: /?ll_ref_id=foobar → /collections/library/?ll_ref_id=foobar
Actual behaviour:
It seems to have no effect. All visitors stay on the homepage regardless of the parameter.
Sure, thank you, will do but what do you mean by steps? As in what is different when we build for production? Nothing except the domain.
I found that this particular netlify redirect works some times but not others. (Our other redirects are fine. This is the only one where url param is a condition)
I now have a js redirect in there client-side as a last resort but it should not necessary.
Many thanks,
George
Aha, I did think there was a delay in the redirect and now you say it’s your JavaScript handling the redirect, which makes sense.
So I checked your site and it appears that the Nextjs plugin is adding its own redirect rules before your custom rules. This is why it’s not working. I used to believe that any customer redirect rules were taking preference. Do you have a repo to check this?
Thanks @hrishikesh , yes the js solution is a failsafe while we try to understand what’s happened to the redirects.
Good spot re Next plugin. Will check for latest. Might we be better off without it? Can’t be sure from the docs what it actually does for the project.
(FWIW Other redirects are very occasionally unreliable too but I’ve not spotted a pattern.)
re “Do you have a repo to check this?” yes we do. But I’m not sure what checks you’d like us to look out for? (Other than “the redirect ain’t working!”
FWIW redirects tend to work when we run netlify dev locally, but may not always work when deployed.
If you don’t use any server side rendering, the yes.
In most cases, I deploy and try the code myself to see what’s causing issues. Also in case of bug reports for the developers, it helps them if they’ve a reproduction ready.