Click to See Complete Forum and Search --> : testing custom apache error messages


crmpicco
11-28-2007, 02:42 PM
I have a set of 5 error message HTML page up on the server now, 400, 401, 403, 404 and 500.

I have 400.shtml, 401.shtml and so on and these files contain the single line:

<!--#include virtual="400.htm"-->


400.htm is just a simple HTML document with a short message:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>AyrshireMinis.com - a Mini E-Community</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="CONTENT-LANGUAGE" CONTENT="EN">
<META NAME="revisit-after" CONTENT="14 days">
<META NAME="robots" CONTENT="all">
<META NAME="Author" CONTENT="Craig Richard Morton">
<META NAME="Copyright" CONTENT="AyrshireMinis.com 2007">
<link rel="stylesheet" type="text/css" href="/mini/inc/style.css">
</HEAD>
<BODY>
<br><br><br><br>
<div style="margin-left: auto; margin-right: auto; margin-top: 100px; width: 600px; padding: 10px; border-style: dashed; color: #FFFFFF; font-family: Verdana; font-size: 8pt;">
<div style="font-size: 28pt; text-align: center;">AyrshireMinis.com</div>
<br>
Sorry, there has been an error.<br><br>
This error (400 bad request), means that a request for a URL has been made but the server is not configured or capable of responding to it. This might be the case for URLs that are handed-off to a servlet engine where no default document or servlet is configured, or the HTTP request method is not implemented.
<br><br><br>
If this error persists, please contact the Administrator at <a href="mailto:email@removedbecauseofspammers.com?Subject=400 Error" style="color: #FFFFFF; font-weight: bold;">info [AT] ayrshireminis [DOT] com</a>
<br><br><br>
</div>
</BODY>
</HTML>


Can anyone advise how I can setup my .htaccess files to get these working properly? My .htaccess file currently looks like:


# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName ayrshireminis.com
AuthUserFile /home/ayrshire/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/ayrshire/public_html/_vti_pvt/service.grp
AddHandler application/x-httpd-php5 .php
ErrorDocument 400 http://www.ayrshireminis.com/400.shtml


I also have a small PHP script - http://www.ayrshireminis.com/mini/400test.php - to allow me to test a 400 error, with the code:


<?php
header("HTTP/1.1 400 Bad Request");
header("Status: 400 Bad Request");
?>


However, no page is shown. Just a blank white page.......

Any help appreciated,
Picco

Scleppel
11-28-2007, 03:01 PM
I also have a small PHP script - http://www.ayrshireminis.com/mini/400test.php - to allow me to test a 400 error, with the code:
...
However, no page is shown. Just a blank white page.......
Apache ErrorDocuments are only sent when Apache encounters the error, not when PHP (or any other server-side language) sends a error status code. To test that it's working (it is) go to /%.

crmpicco
11-28-2007, 05:09 PM
nice one :-)

http://www.ayrshireminis.com/jhjkjkjhkjhkjhkjh - tests a 404
http://www.ayrshireminis.com/% - tests a 400

whats the best way to test a 500 Internal Server Error, because you know i never get them in my coding LOL :-)

Picco

Scleppel
11-28-2007, 05:26 PM
Add the following to your .htaccess file and go to /abc
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^abc /abc [QSA,L]

crmpicco
11-29-2007, 03:48 PM
cheers, that certainly did work. http://www.ayrshireminis.com/abc gives you a 500 Error, i suppose i'll just need to wait until I get one in my coding somewhere to properly test it out with a scripting error??

Incidentally what is that you are doing with the rewrite there?

Picco

Scleppel
11-29-2007, 05:49 PM
i suppose i'll just need to wait until I get one in my coding somewhere to properly test it out with a scripting error??
Unless the server-side language is running as CGI an error is unlikely to cause a 500 error. You could ask in the appropriate forum to make sure, though.

Incidentally what is that you are doing with the rewrite there?
Causing a loop (it rewrites /abc to /abc to /abc...).