Created
February 11, 2013 08:38
-
-
Save apphp-snippets/4753276 to your computer and use it in GitHub Desktop.
This script informs your visitor that a given page may be reached only from the page that you specify. Paste this code before the ending <head> tag on the page:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- source: http://www.apphp.com/index.php?snippet=javascript-specify-referring-page --> | |
| <script type="text/javascript"> | |
| var allowed_referrer = "http://www.yourdomain.com/referring_page_name.html"; | |
| if(document.referrer.indexOf(allowed_referrer) == -1){ | |
| alert("You can access this page only from " + allowed_referrer); | |
| window.location = allowed_referrer; | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment