• 0

Custom Error Handler Not Working


Question

I'm using Apache on Ubuntu to host a local website. I'm using the ErrorDocument directive to forward 404 errors to /cgi-bin/error_404 which is a perl script that looks like this:

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
$server = $ENV{"SERVER_SOFTWARE"};
print $server;

Problem is that in Chrome, it shows up as an error page, even though the HTML source is correct, as you can see in the following screenshots:

post-51387-12733196673444.png

post-51387-12733196754179.png

What really makes me ****ing nuts is that the following works:

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
    $val = $ENV{$var};
    print "${var}=\"${val}\"\n";
}

but this, with a single line change, doesn't (it gives the same problem seen in the screenshots):

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
    $val = $ENV{$var};
    print "What the hell?\n";
}

What am I doing wrong? This is so goddamn frustrating. There are no errors in the Apache log. It works in Firefox, so maybe this is just a Chrome bug.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

You might want to check that your site is sending the proper HTTP status code (e.g. 404). You could use Fiddler (http://www.fiddler2.com) for this. It will work with Chrome by default (as well as IE). I can't imagine it's a Chrome bug. Perhaps you're just not 100% adhering to the proper standards and Chrome is the only browser that isn't just letting you get away with it.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.