Reputation: 105
How do I prevent someone from visiting a page link Directly?
Say for example, i want to prevent people from visiting /blog/index.html directly. They can only visit the link if they come from /home/index.html
I've seen solutions in JavaScript and PHP but most of them look tedious to implement.
I have some HTML and CSS knowledge and have no knowledge on other languages, so what ever help you guys provide, make sure to explain it yeah?
I look forward to your answers! Thanks!
Upvotes: 0
Views: 654
Reputation: 105
Used this from Michel's Duplicate Question Redirect. Thanks for the Answers!
if(!isset($_SERVER['HTTP_REFERER'])){
// redirect them to your desired location
header('location:../index.php');
exit;
}
Upvotes: 0
Reputation:
Add this on the top of your /blog/index.html
:
<?php if(str_replace("http://www.example.com", "", $_SERVER['HTTP_REFERER']) != "/home/index.html"){echo"Error!";exit;}?>
But may be manipulable.
Upvotes: 1