-1

I am providing a URL to users of my web application. The page that the URL links to should only be accessed by typing the URL into the browser's address bar. What are some techniques I can use to determine whether the URL has been embedded in a web page (facebook, blog, etc.)?

Jason
  • 1,129
  • 1
  • 9
  • 20
  • What language? You tagged PHP, and Rails, but which one? – Idris Jul 03 '14 at 23:19
  • theres a google search for that –  Jul 03 '14 at 23:22
  • I use both actually, but will remove PHP as not to flood stackoverflow with the question. My apologies. – Jason Jul 03 '14 at 23:22
  • @Dagon There is probably a google search for every topic discussed on SO, yet the questions are asked and in many cases answered. – Jason Jul 03 '14 at 23:23
  • what i meant was you could leverage the power of google and find if the links have been posted. rather than crawling and scrapeing yourself –  Jul 03 '14 at 23:24
  • @Dagon lol Sorry. That could work, but I will not be able to wait for the indexing. The verification will need to happen faster. – Jason Jul 03 '14 at 23:25
  • then you have to crawl and scrape pages your self which would be impracticable unless you had a known list of pages to search –  Jul 03 '14 at 23:28
  • 1
    You cannot really determine if a link has been posted anywhere, the only thing you can do is to check from where the user comes and hope that he does not fake that header-field: Anyway http://stackoverflow.com/a/3705819/2912456 and http://stackoverflow.com/q/165975/2912456 should be all you need(They are php but answer your question) – Rangad Jul 03 '14 at 23:30

1 Answers1

3

You would have to check the url referer, which is the site the link has been embedded in. The solution in Ruby:

request.referer
ovm
  • 2,452
  • 3
  • 28
  • 51
  • 1
    This is not reliable. You would for example never catch me while I'm at work (default browser settings mask referrer header) – Rangad Jul 03 '14 at 23:31
  • I cant imagine a technique that would be 100% certan, but this one is pretty good and easy to implement – Arctodus Jul 03 '14 at 23:34
  • Never argued that this is be best/only way to do that. Just wanted to remind the asker that this solution is not a 100% solution. – Rangad Jul 03 '14 at 23:35
  • @Rangad It does not have to be to provide a reliable solution to my problem. Since if it has been embedded, the link will be accessed by many different devices, it only takes one visitor providing the proper header info to determine that the link has been placed in a web page. – Jason Jul 03 '14 at 23:39