Trapping or rewriting crappy urls

Hi,

Sometimes in my log, I see correct urls that have been appended with
some crap characters and that currently raises an internal server error
which I don't really care about. What would be the cleanest way to deal
with such situation? Use a begin...rescue?