This question already has an answer here:
How do you access browser history?
In what cases will HTTP_REFERER be empty
I want to create a go back button on a
single.php in WordPress.
I know I can easily do that with
window.history.go(-1) but in the case of the visitor come from another site, I want to redirect to the homepage of my site.
In other words: How can I know if the previous page is an internal link to my site? And if not, redirect to the homepage?