In my site I have a password protected page containing some links to other sites also operated by myself that cannot be password protected. I would like to place a HTML code onto one of the other sites I operate that checks that the person arriving at the page has been referred from the URL of the 'Links Page'.
(I understand that this is not a secure option)
Summary:
If Referrer = 'Links Page URL' *then* Do nothing *Else* Redirect: www.google.com.
Does anyone know a simple HTML/ Javascript code that I can copy and paste into my site?
The address of the webpage where a person clicked a link that sent them to your page. The referrer is the webpage that sends visitors to your site using a link. In other words, it's the webpage that a person was on right before they landed on your page.
To check the Referer in action go to Inspect Element -> Network check the request header for Referer like below. Referer header is highlighted. Supported Browsers: The browsers are compatible with HTTP header Referer are listed below: Google Chrome.
The Document. referrer property returns the URI of the page that linked to this page.
if (document.referrer !== "http://www.stackoverflow.com") {
window.location.href = "http://www.google.com";
}
Or you can use regular expressions to check the referrer.
Anyway, this solution is really, really unsafe. You can just turn off JavaScript in your browser and won't be redirected...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With