Solved

Who is pointing to me?

Posted on 1997-11-01
21
297 Views
Last Modified: 2006-11-17
I got a pretty popular webpage called "myweb.html". Many webpages out there must have a link to my page. Now, I am being curious about who is pointing to my page.

To figure that out, an intuitive way is to use HTTP_REFERRER. But how? I don't want to move "myweb.html" to "someprog.cgi" or "server_side_include.shtml" because it's a tough job to ask those people currently pointing to "myweb.html" to update their links. Not to mention I don't even know what they are and where they are in the first place.

That's why I came up with a way that might help:

out_there.html -(1)--> myweb.html -(2)--> myweb2.shtml

(1): When people follow a link to myweb.html from some web page out there,...

(2): I want to automatically redirect them to "myweb2.shtml" where I can hopefully capture the HTTP_REFERRER using server side include. A lame way to redirect them is to use
<meta http-equiv=refresh content="1; ...>,
but HTTP_REFERRER is gone when it gets to myweb2.shtml.

P.S. server side include only gets executed when the files end with "shtml".

Can anybody tell me how I can figure out who is pointing to me?

Thanks in advance.
0
Comment
Question by:manchung
  • 9
  • 4
  • 3
  • +3
21 Comments
 

Author Comment

by:manchung
ID: 1841425
Edited text of question
0
 
LVL 84

Expert Comment

by:ozo
ID: 1841426
Is your server set up with a RefererLog?
0
 

Author Comment

by:manchung
ID: 1841427
Even if my server is set up with a ReferrerLog, I don't have access to it because the log directory is set to 700 and I am not root.


0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1841429
Trying to locate all the links to your site is probably futile and by changing the name of your page, you'd create even more broken links on the web! I like your idea of keeping the page name as much as I hate broken links ;-)

I don't think you can "preserve" the old referrer, but you can use JavaScript to do what you want to do.
---- quoted from JavaScript guide ----
When a user navigates to a destination document by clicking a Link object on a source document, the referrer property contains the URL of the source document.
Evaluate the referrer property from the destination document.

If the user clicked on a link to get to the current URL, referrer contains the URL the user linked from. referrer is empty if the user typed a URL in the Location box, or used some other means to get to the current URL. referrer is also empty if the server does not provide environment variable information.

referrer is a read-only property.
---- end quote ----

There are several ways to use this property. I'll just give you two:
* From Myweb.html, you can redirect to the next page by using location="myweb2.cgi?ref="+document.referrer; (don't forget a message for poor people without JavaScript ;-) That program delivers your next page and saves the ref-parameter to a file.
* Without redirecting,  you can call a CGI-program in myweb.html by a) including an image that is generated by CGI or b) calling location="somecgi.cgi?ref="+document.referrer; where somecgi returns the "no content" status code (204) that does not change your document.
* If you'd like to rename your page eventually, combine the two by automatically redirecting to "newpage.cgi?ref="+document.referrer and placing a link in the old document like: Page has moved to newpage, please update your bookmarks. If your browser does not support JavaScript-redirects, please <a href="newpage.cgi?ref=unknown">click here</a>to go to the new page.

I don't think there is a solution without scripts - as you can neither use CGI nor SSI in your page, JavaScript is the only solution.
Let me know if that helps ;-)
0
 
LVL 5

Expert Comment

by:Christian_Wenz
ID: 1841430
I agree with Holger, I implemented the document.referrer trick on a page some time ago.
You might alternatively want to set a cookie with the value of document.referrer, but then most people would see that you are setting a cookie. :-(
0
 

Author Comment

by:manchung
ID: 1841431
Thanks, Holger and Christian, for your ideas. Actually, I thought of using javascript also. But, it doesn't work for people using old browsers or those who turned off javascript/java.

I also tried turning myweb.html into some symbolic link to myweb2.shtml on UNIX. Although myweb2.shtml was loaded, the server side include code didn't get executed.

I know it's hard to find a perfect method to retrieve the HTTP_REFERRER this way. Is there a way out there that works in most cases?

Thanks again.


 
0
 
LVL 3

Expert Comment

by:vmpn
ID: 1841432
Write a new file you want and then in myweb.html write something like this page have moved to a new location pleas eupdate your bookmarks.

Sincerely,
VMPN
0
 

Author Comment

by:manchung
ID: 1841433
I did that. It didn't work because, maybe, they were too lazy to update their links.
0
 
LVL 3

Expert Comment

by:vmpn
ID: 1841434
Can you set up myweb.html to be CGI and be executed?
0
 
LVL 3

Expert Comment

by:vmpn
ID: 1841435
Or if you want you can tell me your page address or your provider and I can go look for solutions.

Sincerely,
VMPN
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:manchung
ID: 1841436
CGI programs must end with ".cgi". So, CGI code saved in files with extension html is never gonna get executed.

About my ISP, it's my college. They won't change the configurations of the webserver for me because of security issues.
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1841437
I hereby reserve the (c) for this answer, but I won't have time to test it before tomorrow: What I do on one of my pages to see who has looked at it is:
<a href="mailto:mymail@somewhere.com"><img src="XSlog.pl"></a>
*ggg* - kind of sneaky, but this will call a Perl-Script that does not only return the image (simply the image header and then output the file), but also logs date, time, IP and domain of the "visitor" to a file. It should also be able to save the referrer. This is not a server-side include, it simply requests the file from the server --- I don't know which value the "http-referrer" has in this case (i.e. the page requesting the image or the "original" referrer)... might/should work though.

P.S.: As a JavaScript-Expert I would like to remark that JS IS a way that works in most cases!! *g* For best results, you could do a combination of the methods by enclosing THIS solution in <noscript>-tags ;-)
0
 

Author Comment

by:manchung
ID: 1841438
Holger:

I tried it before. The http_referrer would be "myweb.html" because "myweb.html" refers to "XSlog.pl".

Thanks for your contributions.


0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1841439
Well... as long as nobody offers a better solution, I'd like to "refresh" and modify my first suggestion:

You "cannot" change the name of your main page, so everybody who enters will enter via that page. As soon as you leave it, the HTTP_referrer will contain the URL of your first page => therefore, you have to capture the referrer on the first page. It seems like you can't use either CGI or SSI - as I said before, I think JavaScript is the solution that will give you the best results, it might even be the only one. It's definitely better than nothing and you will soon find out how many people have it / don't have it.
A solution that annoys the lowest number of visitors could also be this:
* include a META REFRESH in the head section that forwards to "newpage.cgi?ref=unknown" after 5 seconds
* include JS-code that beats META to it and forwards to "newpage.cgi?ref="+document.referrer after 1 second.
* include a text message and a link to "...?ref=noMETA" in the document for impatient people and if something goes wrong somewhere...

If you really want to find out badly who might point to your site, you could have your script generate an extra-line if an unknown referrer is passed in. Something like: "I have moved my site. You could do me a great favor by telling me who still has obsolete links to my old URL: [________] [ Submit ]".
I know that's not exactly what you're looking for, but all methods combined should help you find almost everything.

P.S.: I really don't know so much about UNIX (just working knowledge) - but if you could turn myweb.html into a link that loads myweb2.shtml, why can't you turn it into a link that loads myweb2.cgi? Even without any parameters and without SSI, the script would have access to HTTP_referrer...

Good Luck and let me know if you like one of these solutions enough to take it as an answer ;-)
0
 

Author Comment

by:manchung
ID: 1841440
Holger,

 I think your suggestion is the best "work around" for my problem. About the symbolic link I mentioned, although myweb2.shtml seemed to be loaded, the server-side include code didn't get executed -- I was still unable to capture the HTTP_REFERRERER.

 I already have a cgi program at hand that takes the referrer as an arguement and processes it. Can you give me the corresponding JAVASCRIPT code that forwards people to my new page?

 If you don't mind, I will take your suggestions as an answer and I will give you a B.

  Thanks again.


0
 
LVL 5

Accepted Solution

by:
Trevor013097 earned 50 total points
ID: 1841441
Hi,

I had a similar problem on our site, whereby the site was re-structured but old pages where still linked to.  I wanted to find out who was pointing to them and so I use the code below:-

<FORM NAME="MyForm" action="/cgi-bin/referrer.pl" METHOD="POST">
      <INPUT TYPE="hidden" NAME="browser" SIZE=55 VALUE="">
  <SCRIPT language="javascript">
<!--
      document.write("<INPUT TYPE='HIDDEN'NAME='refer' value='"+escape(document.referrer)+"'>");

      var browser = navigator.appName + navigator.appVersion
      document.MyForm.browser.value = browser
//-->
</SCRIPT>
    <INPUT TYPE="image" SRC="moved.gif" border=0>
  </FORM>

This script will also give you the browser of the person who visited your page.  Useful if you want to ensure compatibility of features, and need to know how many people are using your recommended browser.

To see it in operation then goto:-

http://www.pcmaritime.co.uk/news/stena.htm

Cheers,

   Trevor

0
 

Author Comment

by:manchung
ID: 1841442
I tried your suggestion. It worked.

0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1841443
Glad I could be of help.


0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1841444
ok, people.... I'm really almost always a "nice guy", but I have to tell you that I am not exactly thrilled about this turn of events - not so much for the points as for general "netiquette"...

1] I proposed a better solution than this in my very first comment. Your complaint was that it wouldn't work without JavaScript and that's what all my following comments were about!
2] My last solution offered a combination of 3 strategies that give you decent results even without JavaScript.
3] You had already agreed to accept my "answer" - I'd understand it if somebody had posted an alternative solution that does everything you want, but this one does less than what I proposed!
4] My solution would have been "almost invisible" to your visitors - this one isn't.
5] A solution doing the exact same thing that this one does only has to take one line of JS-code and one line of HTML-Code!!
6] Having posted an almost complete solution, I feel that this is a "Reject" for which I don't really see a good reason!!
7] You accepted fast enough so I had to "pay" to see which solution was posted!

This really takes me back to locking questions as soon as I know I can answer them! I left it open for somebody to post a "non-JavaScript" solution that might be able to preserve the HTTP-REFERRER, not for a shortened version of my comments!

P.S.: The only results you will ever get for browser are NN, IE and possibly AOL-browser... why pass it in anyway? HTTP_USER_AGENT should do it...

still: no (very) hard feelings, I just wanted to point that out and refer you to the "Expert grading help"...
0
 

Author Comment

by:manchung
ID: 1841445
Holger,

Actually, I was waiting for your answer yesterday. But, Trevor jumped in before you did and he offered me an answer, not a comment. I didn't really know what to do. I coundn't give him an F.

To be fair to you, I came up a "work around". I think, i still have 20 points left in my account. I can post a similar question. You thenrespond with a simple answer and you get an A.


Sorry again.
0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1841446
Look Holger, I just gave the answer that was required plus a little extra.  Browser was never a requirement of the original so why critize it?

It actually returns many browsers:-

IE 2.0
IE 3.0
IE 4.0
NN 2.0
NN 3.0
NN 4.0
AOL 3.0
AT&T WorldNet Service3.0C-WorldNet

Plus it also returns the platform that the user is on.

Your first comment mentioned using JavaScript but did not actually give any examples, so I hardly posted your comment.  As for netiquette, I hardly think a flame is netiquette do you ;-)




0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now