Hacker News new | ask | show | jobs
by jamies888888 733 days ago
If you're going to do this then make sure you use 302 redirects (temporary) and not 301 (permanent). Otherwise browsers (and Google) will cache the redirect, then if your fuzzy matched URL one day becomes a real URL, people might not be able to access it.

Someone could seriously mess up your site by simply publishing their own page with many invalid links to your site, basically a dictionary attack, and if Google was to crawl those links, they'll cache all the redirects, and you'll have a hard time rectifying that if you were wanting to then publish pages on those URLs.

Also to reiterate other suggestions - your idea is not great for many reasons already stated (even with 302s). As suggested, just simply have a 404 page with a "Did you mean [x]?" instead. Use your same logic to present [x] in that example, rather than redirect to it.

1 comments

I am still rolling this out to other parts of the website, but here is the new 404 page format https://pillser.com/engineering/2024-06-10-website-without-4...

As described elsewhere, here is how the new logic will work:

- I will track which URLs are associated with which products

- If user hits 404, I will check if there was previously a product associated with that URL and redirect accordingly

- If it is a new 404, I will display a 404 page which lists products with similar names