473,378 Members | 1,397 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

404 Error Referer Script Problems

Hello,

I am having trouble extracting the original referer in my 404 error script.
This is what I have so far:

1) I set the .htaccess file to the following and it works fine:

ErrorDocument 404 /404.php

2) I've tried the following variables and they all produce the same results:

$REQUEST_URI
$HTTP_REFERER
$REDIRECT_URL

3) The above mentioned variables all return "/404.php" and not the
originally requested page.

I'm a little new at this and any assistance would be greatly appreciates!

Many Thanks,

Alex
Jul 17 '05 #1
2 4875
On Thu, 18 Sep 2003 09:12:53 +0000, Alex wrote:
I am having trouble extracting the original referer in my 404 error script.
This is what I have so far:

1) I set the .htaccess file to the following and it works fine:

ErrorDocument 404 /404.php

2) I've tried the following variables and they all produce the same results:

$REQUEST_URI
$HTTP_REFERER
$REDIRECT_URL

3) The above mentioned variables all return "/404.php" and not the
originally requested page.

I'm a little new at this and any assistance would be greatly appreciates!


$REQUEST_URI returns the correct thing for me.

Cheers,
Andy
Jul 17 '05 #2


I am having trouble extracting the original referer in my 404 error
script.


What you want is:

<?php
if (isSet ($_SERVER['HTTP_REFERER'])) {
# if (eregi (('http://' . $_SERVER['SERVER_NAME']), $_SERVER['HTTP_REFERER'])) {
echo "\n<p>A message to the webmaster has just been sent automatically, to inform her/him to make arrangements$

$recipient = 'webmaster@YOURDOMAIN';
$website_name = 'NAME OF WEBSITE';

$subject = "{$_SERVER['SERVER_NAME']} error: 404 (non-existent resource)";
$mailheaders = "From:$websiteName website monitor <$recipient>\n";
$message = "\nA 404 message was generated from someone loading a resource on {$_SERVER['SERVER_NAME']}\n\n";
$message .= " The resource is at {$_SERVER['HTTP_REFERER']}\n";
$message .= " which attempts to load http://{$_SERVER['SERVER_NAME']}{$_SERVER['PHP_SELF']}";
$browserDescription = (isSet ($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '');
$message .= "\n\n" . $_SERVER['REMOTE_ADDR'] . "\n" . $browserDescription;
mail ($recipient, $subject, wordwrap ($message), $mailheaders);
# }
}
?>


(Sorry if the lines wrap.)

Uncomment the two lines beginning with # if you want to enable broken link
detection for referrers ONLY within your site.

Bear in mind that you will get a few spurious results due to badly
configured spambots/scumbots and all sorts of other rubbish out there. If
you get a referrer of www.iaea.org I personally would ban that IP.


Martin Lucas-Smith www.geog.cam.ac.uk/~mvl22
www.lucas-smith.co.uk
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
5
by: Joshua Beall | last post by:
Hi All, I do web design for some small organizations, and one of the sites I have set up takes online conference registrations. Now, most of the time it works. In fact, every time I try it, it...
3
by: Giuseppe | last post by:
I need to make a little software to know how many visitors see my websites, and where they come from. So I've added this code at the end of a webpage: <!------- Begin Stat code ------------->...
8
by: JA | last post by:
Hi, I have this JavaScript that is supposed to show random products from my database, and show something different every time you refresh or revisit. But I keep getting an error - on my computer...
2
by: FrankStallone | last post by:
I am just getting started in XML and I made my first xml, dtd and xslt file and XML spy said they were all valid and they worked. This was the xslt doc that worked. <?xml version="1.0"...
2
by: me.linuxadmin | last post by:
hi all ive got php-4.3.9-3 on my fedora3....tried installing phptimesheet-1.2.4.tar.gz on my system..extracted the folder to document root of apache2..all the files of the timesheet have php3...
1
by: Al | last post by:
Hi i'm having troble with a script where i check referer, on a PC with Zone Alarm Pro the referer isn't send... i did a couple of page of testing and no referer is sand, closing ZAP the...
2
by: pranas | last post by:
I'm not a proffessional programmer and I'm asking for your help. I'm using PHP and running Apache server and Mysql database server on my home network computer to serve my web site. My PHP error log...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.