# Redirect if not referred from specific page

**URL:** <https://forum.kirupa.com/t/redirect-if-not-referred-from-specific-page/57746>\
**Category:** programming\
**Created:** [July 15, 2004, 8:50pm UTC](https://forum.kirupa.com/t/redirect-if-not-referred-from-specific-page/57746 "2004-07-15T20:50:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtesp](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jtesp](https://forum.kirupa.com/u/jtesp)\
**Post date:** [July 15, 2004, 8:50pm UTC](https://forum.kirupa.com/t/redirect-if-not-referred-from-specific-page/57746/1 "2004-07-15T20:50:13Z")

</div>

Here’s the scoop:  
I don’t want anyone adjusting the id url parameters and accessing pages they shouldn’t be seeing.

So basically…how do I make it so details.php is ONLY accessible by clicking a link from the master.php page? I don’t want anyone to be able to access it by typing in the url, and I don’t want it to be clickable through any other link other than master.php thats on my site. If it’s hotlinked or directly accessed, I want to redirect them to index.php

Is there a php solution? Or an .htaccess solution? I have no idea how to do this and it’s driving me nuts! Please help!

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 15, 2004, 9:25pm UTC](https://forum.kirupa.com/t/redirect-if-not-referred-from-specific-page/57746/2 "2004-07-15T21:25:37Z")

</div>

There are different ways to do this. One is to check $\_SERVER[‘HTTP\_REFERER’] (note that it is misspelled) field which should contain the URL of the referring page. I say ‘should’, because some browsers don’t provide it. So it won’t work for some users.

Another option could be to create a session variable on page one and check that it is set on page two. Then the user can enter page 2 anytime and by any means, provided they’ve been to page 1.

I’d use the last method if it were me.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 15, 2004, 10:10pm UTC](https://forum.kirupa.com/t/redirect-if-not-referred-from-specific-page/57746/3 "2004-07-15T22:10:55Z")

</div>

Thanks, that sounds good. Too bad I have no clue how to do this! I’m using Dreamweaver in case that helps. Is there a tutorial or some sample code I can see? I do not know where to begin with this.  
Thanks
