Support Forums

Use _redirects to redirect 404 from a dir as a query

Hello! I have my website all running well and all but I have /users directory and a user profile would be /users/example.

I want to make it so if the user page yields a 404error it would redirect /users/example to /usersearch?user=example

I looked into the documentation and I was dumb and couldn’t get it working :sweat_smile:

Thank you in advance to anyone who helps!

Hi @StreetyYEET,

Would you give this a try:

/users/:username/ /usersearch?user=:username 404

I’m not 100% sure if it will work, but worth a shot.

I added it but it seems like the query string is not being provided


On the first one it loads infinitely which suggests there is no query string provided since it before loading has a if statement which gets passed only if there is a user query present

Hi @StreetyYEET,

I see, well, there’s this one last thing you can try, and if it doesn’t work, you’d most likely have to rely on JavaScript for a client-side redirect.

/users/* /usersearch?user=:splat 404

On a side note, the background that you’ve used for your website seems to be a wallpaper from macOS. Do note that, if it’s a copyrighted image and someone files a DMCA complaint against it, we might have to take your website down. It’s better to change it to be safe.

That unfortunately didn’t appear to work either. I might need to implement client-sided check with JavaScript.

Thank you for your concerns regarding the background image used in that project. Unfortunately I do not have the competence to allow any modifications in that regard. Please send a letter to the address legal@riigikohus.com, they might be able to check that out.