so what I would like to do is have a link on an external website (example: externalsite.com) that will go to mywebsite.com/page.php, and I need to make it so ONLY clicking on the link from externalsite.com will allow you to access mywebsite.com/page.php.
The user cannot simply type it in their browser to get there, how would I go about doing this?
so what I would like to do is have a link on an external
Share
Given that no method is 100% secure, I’ll show you a very easy, overtly insecure method that will work in any framework because it’s pure JavaScript. Keep in mind that this is designed to work only as a general rule and is in no way “hacker proof”.
Simply add this script to your
mywebsite.com/page.php. It will redirect any request that isn’t referred by a page onexternalside.com.To get around the whole “if you disable JavaScript, this doesn’t work, you idiot” dilemma, add
id="myBody" style="display: none;"to your page’s<body>tag: the page will not be displayed unless JavaScript is enabled and validates the referring URL. Also, I’m not an idiot.There are several ways to bypass this method: spoof the referring url, use FireBug to remove
display: none, view the source of the page and recreate it on your local machine, etc. This method is more of a deterrent than a security feature.