Redirect domain.com/?search=123 to domain.com/123

How to redirect abcmaindomain.com/?search=123 to abcmaindomain.com/123

I tried /?search=:d redirect to /:d/

but no effect.

Can anybody suggest the appropriate method with redirection in the Render Redirect rule.

Hi there,

Thanks for reaching out.

That redirect wouldn’t work in this case. Static site redirect and rewrite rules are only matched if no existing content is found at a path.

Your example in full would be domain.com/index.html?search=foo, I expect index.html exists, so the redirect wouldn’t fire as a file is found.

You could either move it to a non-existent path, e.g.
/no-real-path/?search=:d/:d/

Or if your using a JavaScript framework you may be able to achieve what you need with client-side routing, e.g. ReactRouter.

Hope that helps

Alan

This is CRUCIAL information that is not displayed on the actual page for Redirects/Rewrite rules.
And it should be.
I’ve been trying to rewrite /index.html (which obviously exists) to / for the better part of the afternoon.

1 Like

How did you fix the issue, I’m currently dealing with the same problem.