Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

get referring pages for 404 mail to webmaster

is there any way to make a 404 page that can email to a specific address the page the user was trying to reach when he or she got the 404.  The examples I've seen online just print out 404.php when they try to email where the user came from, which is not very useful. I've tried working with javascript referrers (but they seem only to work if a link is pressed, not something mis-typed or given to the user incorrectly), and some php $_SERVER inquires, but i can't seem to get it to work..

Grateful for any ideas!
Thank you.
0
hibbsusan
Asked:
hibbsusan
  • 7
  • 4
1 Solution
 
Hendrik WieseInformation Security ManagerCommented:
Hi,

Please refer to the following link to setup a 404 page that emails: http://net.tutsplus.com/tutorials/php/404403-website-error-pages-with-php-auto-mailer/
0
 
hibbsusanAuthor Commented:
for me, this just shows the 404.php file as the url that access was attempted on.  can't i get the site that the user typed in?

Thanks!
0
 
hibbsusanAuthor Commented:
my last post was worded poorly.

In the email I receive from this script, I would like to see what url the user tried to load.

for example: user wants to see the page with images, so he types:
 www.mysite.com/images/

and he gets a 404 because the url that has images is actually located at:
 www.mysite.com/img/

in the email I receive i would like to see:
"User got a 404 when he tried to go here:  
www.mysite.com/images/"

But with this program, I see:
"User got a 404 when he tried to go here:
 www.mysite.com/404.php"

well, or course that's not what he tried to access. That's just the last page he was on, and pretty useless :(

Is there anyway to see exactly when he typed in the browser before being re-directed to the 404?

Thanks!
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
Hendrik WieseInformation Security ManagerCommented:
Hi,

With regards to the link I posted, you will get a notification that the user was trying to access http://www.mysite.com/images and not the 404.php url. It will however not be able to tell you that the actual location is http://www.mysite.com/img as you cannot determine this.

So in short:
1. You will receive an email showing you the page that the user was trying to load for example: www.yoursite.com/images
2. You cannot determine what it should have been using code: The only way to do this would be to Analyse the result that the script sends you and then create an additional directory called img and add a page with the same name that directs the user to the correct location.
3. Same as point 1
4. This example that I posted will not send you the www.mysite.com/404.php as it captures the url that the user was trying to access from the start.

Hope this helps!!!
0
 
hibbsusanAuthor Commented:
First of all, I definitely don't expect this to redirect the user to the appropriate page, or anything like that. I just want to get an email with the incorrectly typed address.

I wish I could get this software to work like this. I've set it up and it really does simply send me the 404.php url. There are several similar comments on the site. I imagine it's a simple matter of overlooking something obvious, because the author has set it up so you only have to plug in about three variables.

Have you got a working sample of the code I could look at? Or could you forward one of the emails so I could see it in action?

Thanks for your help!
0
 
Hendrik WieseInformation Security ManagerCommented:
I have tested it on my domain and the output was the following:

There was a 404 Not Found error on the www.helewix.com domain

Details
----------------------------------------------------------------------
When: Mon Sep 19 2011 12:13:36 pm SAST
(Who) IP Address: 66.249.72.153
(What) Tried to Access: http://www.helewix.com/main/index.php?page=shop.ask&flypage=flypage.tpl&product_id=251&category_id=63&option=com_virtuemart&Itemid=59
(From where) HTTP Referer:

User Agent: Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
0
 
hibbsusanAuthor Commented:
For me it looks like this:

 404 email notification
0
 
hibbsusanAuthor Commented:
do you have any ideas? can I see a copy of your code and .htaccess?

I can't figure out what the problem could be ><

Thanks!
0
 
Hendrik WieseInformation Security ManagerCommented:
My .htaccess has got the following 2 entries in as suggested by the site:

ErrorDocument 404 /error/404.php  
ErrorDocument 403 /error/403.php

404.php

<?php 

header("HTTP/1.0 404 Not Found");	// Send correct HTTP Header
$error_code = '404 Not Found';		// Specify the error code
require_once('http://www.helewix.com/error/error-mailer.php');	// Include the error mailer script

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

<head>
<title>404 Not Found - The page or file you requested does not exist.</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<link href="http://www.helewix.com/error/styles.css" rel="stylesheet" type="text/css" />
</head>

<body>
	<div id="wrapper">
		<img src="http://www.helewix.com/error/oops.jpg" alt="404 Error Oops!" title="404 Error Oops!" />
		<h1 class="loud">Sorry! We couldn't find it.</h1>
		<p class="loud">You have requested a page or file which does not exist so we 
		notified the web administrator to check it out.</p>
		<p class="small">Here are a few options to find what you are looking for.</p>
		<ol>
			<li><span>Double check the web address for typos</span></li>
			<li><span>Head back to our home page via the navigation below</span></li>
			<li><span>Contact us by <a href="http://helewix.com/contact-us.php">clicking here</a></span></li>
		</ol>
		<ul>
			<li><a href="http://www.helewix.com">Home</a></li>
			<li><a href="http://www.helewix.com/blog/">Blog</a></li>
			<li><a href="http://helewix.com/free-fax-to-email.php">Free Fax to Email</a></li>
			<li class="last"><a href="http://helewix.com/contact-us.php">Contact</a></li>
		</ul>
	</div><!-- end div #wrapper -->
</body>
</html>

Open in new window

0
 
hibbsusanAuthor Commented:
Can you attach your directory?

i'm confused about this folder 'error'. it is not in the downloadable files on the site, but he references them (as do you) in your .htaccess and in the 404.php file.

Thanks!
0
 
hibbsusanAuthor Commented:
thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now