Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Referer code on NT server

Why doesn't this code work?

7:59 pm on Feb 20, 2004 (gmt 0)

New User

10+ Year Member

joined:Feb 13, 2004
votes: 0

I am trying to run the a script that contains the following code to log referer data, but it does not work. It does write to the log file, but instead of showing the page and the referer, it seems to just log the destination file for both.

Example from log:

www.mydomain.c0m/destinationpage.shtml -> mydomain.c0m/destinationpage.shtml

My understanding is that this was written for Unix and my server is NT. I am VERY new to Pearl and have no idea what I need to change to get this to work correctly.

Can anyone spot the problem or advise based of the snip of code I have posted below? Let me know if you need more info...

Thanks for looking!

if ($RefererFile &&!($NoCountHit)) {
open (COUNT,">>$RefererFile");
if (defined $ENV{'HTTP_REFERER'}) {
$doc_referer = $ENV{'HTTP_REFERER'};
else { $doc_referer = ""; }
if ($doc_referer && $doc_uri) {
unless ($IgnoreIntRefs && ($doc_referer =~ m#$server#oi)) {
print COUNT "$doc_referer -> $doc_uri\n";
close (COUNT);

8:52 pm on Feb 22, 2004 (gmt 0)

Preferred Member

10+ Year Member

joined:Dec 19, 2000
votes: 0

>www.mydomain.c0m/destinationpage.shtml -> mydomain.c0m/destinationpage.shtml

If the code snippet in your post is the part that prints the example line from your logs the first part should indeed be the referrer ,as it says that $doc_referer = $ENV{'HTTP_REFERER'};

It is printed in this line:

print COUNT "$doc_referer -> $doc_uri\n";

The snippet does not show what $doc_uri is, so it's impossible to tell if that could be the cause of the problem.

Note that if you did not configure $IgnoreIntRefs (and $server) somewhere, a browser-reload might cause your logs to look like your example. (A page on your domain is both the referrer and the destination). It looks like mydomain.com ($server) can be excluded as referrer by setting $IgnoreIntRefs.