Not too hard, if the site already has some kind of a search engine, it can feed the URL to the search engine.
The safe thing to do is return a 404 with a few suggested links.
The problem is that "guessing" the intent of the URL will have unintended consequences. A URL will no longer be guaranteed to point to what you think it points to. This fundamentally breaks the assumption of what a URL is.
How could this happen?
1: Site creates article foo.com/chocolate_bars
2: Someone accidentally links to foo.com/cocoa_bars, which serves foo.com/chocolate_bars
3: Site creates article foo.com/coco_bars
4: Now foo.com/cocoa_bars serves foo.com/coco_bars
Yes, this sounds like a nightmare. Also pity poor archive.org if they try to archive a web site set up like this - every URL will resolve to a valid page.
My thought was to serve a 307 (or some other redirect HTTP code, clearly I am not a web developer) instead of a 404, not to serve the found content “as” the url that didn’t exist.
But agreed this would not be good general practice. It was mostly a thought experiment.
The safe thing to do is return a 404 with a few suggested links.
The problem is that "guessing" the intent of the URL will have unintended consequences. A URL will no longer be guaranteed to point to what you think it points to. This fundamentally breaks the assumption of what a URL is.
How could this happen?
1: Site creates article foo.com/chocolate_bars 2: Someone accidentally links to foo.com/cocoa_bars, which serves foo.com/chocolate_bars 3: Site creates article foo.com/coco_bars 4: Now foo.com/cocoa_bars serves foo.com/coco_bars