Redirects from query string routes to slug based routes

Hi all, I’m attempting to redirect from some legacy routes to a new routing scheme and having some trouble. Each system uses query strings, but the previous system used an ID based system while the new one is using slugs and a namespaced route. Here’s a few examples from my _redirects file:

/?topic=er  /roster?category=all
/?cat=1000  /roster?category=Instrumentalists%20%26%20Ensembles
/?cat=1010  /roster?category=Vocalists
/?cat=1020  /roster?category=Conductors

Is this possible through Netlify redirects? I’m not seeing this functional on my deploy preview, at least. I’d welcome any direction or input here. Thanks!

I’ll update here as I try things.

I tried a different approach for one of my rules based on the Query Params section of the redirects docs:

/ topic=er  /roster category=all

This is giving me a 502 on my deploy preview here: https://deploy-preview-180–

After spending a good chunk of the day on this, I haven’t been able to make any progress. I’ll include my _redirects file in its entirety for clarity below as a Gist to save space here:

Here’s a functioning link (Discourse is doing something funky above) to the topic=er redirect I’m mentioning above: https://deploy-preview-180–

Here are a few of the other links that should be redirecting for which I’ve preserved my original approach - these all just wind up on the home page and don’t execute any redirects:


Let me know if there’s anything else I can provide to add clarity here.

Hello @kpollich, it doesn’t look like your redirect rules are formatted correctly. As mentioned in our redirects doc, your redirect rule should look more like the following:

/ cat=:value /roster/category/:value

You won’t be able to create a redirect rule that checks the params like you are doing. You can only pass on the value of the param to the path you are redirecting to. In my example, if your root path had a param like /?cat=orchestras, it will get redirected to /roster/category/orchestras`.

Let me know if that helps.

Thanks for your reply, Dennis.

That’s definitely a disappointment that I can’t implement the redirects based on query strings. I think I can potentially stitch something together with a redirect like you’re mentioning that forwards the request to a route which then handles processing the legacy query strings and redirecting further.

Yea, that sounds like a good workaround.

Working through this now and looks like this will be a workable solution for me. Thanks for your help, Dennis!