?
Solved

error 404 - automatic email

Posted on 2003-03-11
5
Medium Priority
?
167 Views
Last Modified: 2010-03-04
Hi.
I have the:
ErrorDocument 404 /missing.html
working OK, and a pretty message going to the user.

But how do I get this page to automatically email me the URL they were tring to go to, and/or where they were coming from (which page has the bad url on it)

Can this be done?

Thanks
0
Comment
Question by:arobertson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 15

Expert Comment

by:samri
ID: 8117437
arobertson,

You could redirect the 404 Error to some cgi scripts, which could return the $ENV{REQUEST_URI}, back to user, or as email it to you as you wish.

cheers.

0
 

Author Comment

by:arobertson
ID: 8123499
Not up on CGI.
Can you point me to a sample?

Thanks
0
 
LVL 15

Accepted Solution

by:
samri earned 200 total points
ID: 8125699
Aron,

What is your OS.  If you are running Unix then, it will be much easier, since I would use perl.


-- some rude code that I had.  Mine is running on Win2K with ActivePerl.  You if you are running on Unix, change c:/perl/bin/perl to /bin/perl (or /usr/local/bin/perl) or wherever your perl is)/

---

#!c:/perl/bin/perl

use CGI;
use Mail::Sendmail;


my $q=new CGI;

print $q->header;
print $q->start_html;
my $remote_addr=$ENV{'REMOTE_ADDR'};
my $referer=$ENV{'HTTP_REFERER'};
my $url=$ENV{REQUEST_URI};

print "404 Not Found<br>";
print "$url<br>";
print "<hr>";

print $q->end_html;


 %mail = (
   To => 'Your Name <userself@yourdomain.com>',
   From => 'Web server <weberror@webserver>',
   Subject => 'Web Error',
  'X-Mailer' => "Mail::Sendmail version $Mail::Sendmail::VERSION",
 );

 $mail{Smtp} = 'yoursmtp.domain.com';
 $mail{'Message : '} = "FROM IP\t:$remote_addr\nFROM URL\t:$referer\nURL:$url\n";

  sendmail %mail;

# the following will print a debugging on browser.
# if (sendmail %mail) { print "Mail sent OK.\n" }
#   else { print "Error sending mail: $Mail::Sendmail::error \n" }
# print "\n\$Mail::Sendmail::log says:\n", $Mail::Sendmail::log
----

cheers.
0

Featured Post

Simple, centralized multimedia control

Watch and learn to see how ATEN provided an easy and effective way for three jointly-owned pubs to control the 60 televisions located across their three venues utilizing the ATEN Control System, Modular Matrix Switch and HDBaseT extenders.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 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