The site has a bunch of redirects that are spread over php routing. And there are situations like
/ site / loop1> / site / loop2
/ site / loop2> / site / loop3
/ site / loop3> / site / loop4
/ site / loop4> / site / loop5
/ site / loop5> / site / loop6
I give myself the accountability that before a redirect it is possible that “something” is happening (it is written during the session or something else). But obviously it is necessary to get rid of this, so that in the end a direct redirect will turn out
/ site / loop1> / site / loop6
The blessing though all redirects are made through a wrapper, a certain function redirect in which I would like to put redirects in a stack and if the chain was formed. At the end point of the exit, it was written to me somewhere (for example, to a database). For further disentanglement of this ball.
So far it only comes to mind that $_SERVER['HTTP_REFERER']
added to the session with each redirect and analyzed after leaving the chain.
How is it properly organized, so I did not do a bicycle?