How to identify if referrer is a 301 redirect

前端 未结 5 1536
悲&欢浪女
悲&欢浪女 2020-12-21 15:46

I\'m implementing a slug system for my website at the moment. I plan to redirect invalid slugs to the correct on that is stored in the database. E.g.

5条回答
  •  醉梦人生
    2020-12-21 16:21

    Found a working solution:

    • Start session.

    • Check session, if $_SESSION['INVALID_SLUG'] exists display message then unset session

      else

    • Retreive slug from database e.g. /11/right-slug

    • Get current URI e.g. /11/wrong-slug

    • Compare, if different set $_SESSION['INVALID_SLUG'] and redirect to correct page

    Any feedback? I realise this will not detect a 301 redirect itself more detect a trigger assosiated with the redirect.

    Thanks for all the help.

提交回复
热议问题