restrict access to a page unless from...

1erik1

Member
Messages
61
Reaction score
1
Points
6
hey can anyone teach me how to restrict access to a webpage, let's say domain.com/home.html, unless you are coming from domain.com/index.html

whatever is the best way to do it I think i read somewhere about headers? but I am completely lost.

unfortunately I have no points to dish out since I spent them all on a raffle I lost :p
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
hey can anyone teach me how to restrict access to a webpage, let's say domain.com/home.html, unless you are coming from domain.com/index.html

whatever is the best way to do it I think i read somewhere about headers? but I am completely lost.

garrettroyce's answer best matches what you asked (the Referer header tells you what page a visitor is coming from), but it may not be what you need. Very important question to answer: why do you want to restrict access based on where a visitor is coming from? It's best to always post the overall goal in addition to a problematic step as there may be a better way of achieving the goal.
 

primefalcon

New Member
Messages
15
Reaction score
0
Points
0
pretty easy thing to do

PHP:
<?php
$urlToCheck = $_SERVER['HTTP_REFERER'];

if($urlToCheck != "http://onlyletthisurlthrough.com/index.php")
{ exit("you are not aloud to be here"); }
else { /* do nothing, they're aloud */ }
?>
 
Last edited:
Top