Preventing users from opening index directly

hey folks,
i m working on a website. in which i m using a page which calls on index.php after that web address is called. as it has JS function which make index page open in popup. what i wanna do is now is that if someone (as many of us know root page 90% is index.php), if anyone enter index page directly. JS should check if that person came from redirect.php or not. if not, he will have some sort of error msg. how can i achieve this?

You can’t

  1. Not everyone has JavaScript enabled
  2. The referrer field is under your visitors control and can contain anything they like