Turbo search form submit, update URL when destination returns 404 status

We have a search form that takes a user from site.com to site.com/search?term=keyword when they submit the form.

This works great, and the user is able to click the back button to return to site.com after performing a search.

However, the /search route returns a 404 status when there are no results found. If a user searches for a term that doesn’t exist like asdfasdfasdfasdf then the URL does not update after the form submission. The page displays all ok with “no results found” but the actual URL in the browser stays at site.com instead of site.com/search?term=keyword

Is there a way we can tweak turbo to change this behaviour for updating URLs when it encounters a 404 ?


Fix your controller to return 200 or another success-adjacent status if there are no results. Show a page that says “sorry, no results from your search for ‘wakka’”. I understand where you’re coming from with the 404, but that’s a different answer than you mean. That sounds more like “we used to have a search page, but now we don’t”.