473,656 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4889
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@YOUR DOMAIN';
$website_name = 'NAME OF WEBSITE';

$subject = "{$_SERVER['SERVER_NAME']} error: 404 (non-existent resource)";
$mailheaders = "From:$websiteN ame 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']}";
$browserDescrip tion = (isSet ($_SERVER['HTTP_USER_AGEN T']) ? $_SERVER['HTTP_USER_AGEN T'] : '');
$message .= "\n\n" . $_SERVER['REMOTE_ADDR'] . "\n" . $browserDescrip tion;
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
5025
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 double-checked the path to my error log. It is in /var/www/logs/php_error_log Thanks. :) -Wayne Stevenson
5
2802
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 works fine. However, after having many complaints about it not working right, I finally discovered that some of my users do not have the page referer set when they request my page, and I was checking on the form submission page to make sure...
3
5650
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 -------------> <script language="JavaScript"> var path = 'http://www.mysite.com/webform1.aspx'; document.write('<img height=1 width=1 border=0 src="'); document.write(path); document.write('?referer=');
8
2967
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 - that says Syntax Error in Line 2. There is no error on most other computers, and the products show, but another script on the page, an article title scroller, stops - on most computers, but not all. It says "no articles available".
2
1629
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" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/">
2
1650
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 extensions... php is working fine on my sys but php3 is not interpreted...when i go to //localhost/timesheet/timesheet.php3...i can see the source code of the page like... <?............................
1
2236
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 referer will work How can i solve this, do you know wich option is in zone alarm that dosen't send referer
2
9267
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 is getting as big as more than 1MB daily. Looks like somebody is bombarding my site with strange requests constantly and I believe it is slowing my server. I'm correct? If so, how I can get rid of that?Below is example of my error log: client sent...
10
6960
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 of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
8297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1600
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.