如何根据SQL中的caracters相似度比较字符串?

I'm working on redirecting people if they type a "not really wrong url".

For example I have a good URL http://www.website.com/category/foo-bar-if-bar-foo/. This one works so if a user enter to my website with it, I can retrieve the article corresponding.

But if someone enter to my website with a not really wrong url like http://www.website.com/category/foo-bar-foo/ because an another website has referenced a wrong url, I should redirect him to the right one instead of having a 404 status code...

So how should I do this? and Most important, should I do this ?

I actually use Eloquent with Laravel 4.2.

Thank you in advance.

EDIT

I was wrong about stackoverflow, thanks for your comment. It uses the unique ID of a post.

EDIT 2

I Looked at SOUNDEX function in SQL, it's really good if there is a small difference like a character or two missing. But if my url is as broken as my example, it's not working anymore obviously. But thanks it's gonna be usefull.

Just thinking off the top of my head, you could create a SQL table (with Full-Text indexing enabled) containing all your paths (it might already exist).

In the event that a 404 is triggered, hijack that and do a MATCH (Full Text Search) and return the path with the highest scoring MATCH (you can also consider using a score threshold to prevent nonsensical matches).