redirect 404 to similar urls

前端 未结 6 947
情深已故
情深已故 2021-01-30 11:16

I have a website with stories in it. I can have multiple types of stories within multiple categories like:

  • children
  • romance
  • scifi
  • action
6条回答
  •  旧时难觅i
    2021-01-30 11:40

    There are a few solutions:

    • Identify the source of the faulty URL's. This simply should not happen, and I can't imagine why it does. Are other people linking from elsewhere and they made a typo (ignoring the existence of copy&paste)? Can you see where this comes from (referer) and contact them?
    • Add an ID to the URL, so /action/123/story-name-action, where you look the article up on ID and not on its title (bonus: adds the possibility to create multiple stories of the same category with the same title)
    • Do a fuzzy search on the title, using something like soundex, and redirect the user to the most fitting title or show an overview page with look-alike titles like @symcbean suggests.

    I prefer the ID one though.

提交回复
热议问题