Take the 2-minute tour ×  Is it possible to have the router
return an error code (or an entire rack response) in response to
a matched route?  E.g. I have move from WordPress to a home
grown blogging solution. Search engines are hitting URLs like
'/?tag=ruby' that need to return a 406 error. Instead, the
router dutifully routes them to the same place as '/' I can
match the URLs I want to get rid of but I don't know what to do
with them  share|improve this question add comment  1 Answer  up
vote 0 down vote accepted  This is not obvious, but it is
effective.   match('/',:query_string=>/.+/).defer_to do
|request, params|   raise
Merb::ControllerExceptions::NotAcceptable,          "Query
String Unknown: #{request.query_string}"   In order to trigger a
406 error we need to raise
Merb::ControllerExceptions::NotAcceptable but if we do this
while setting up the routes it helps exactly no one. Instead we
need to wait until Merb is handling the request. this is what
the defer_to block does. When the request comes in w