Da manuale:

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

Come vedi non è il massimo in fatto di affidabilità o di sicurezza.

In alternativa puoi mettere in sessione $_SESSION la pagina di provenienza e recuperare il dato nella pagina di login e poi effettuare il redirect.