...

View Full Version : how to test custom error messages



crmpicco
11-26-2007, 11:10 PM
Can anyone tell me how I can test out custom error messages I have created for my website, the site is running on an Apache web server. At the moment there is a 400.shtml file up there which is calling a 400.htm file.

What I have just now.......
www.ayrshireminis.com/400.html

Many Thanks,
Picco

Apostropartheid
11-27-2007, 04:47 PM
Generally helps if you give us the right address (http://www.ayrshireminis.com/400.htm).

crmpicco
11-27-2007, 10:39 PM
LOL - yea, good one :-)

Have you ever done this before? I just wondered if there was a good way to test all the different types out or if it is just a case of put them up on the server and hope they do not appear :-)

Annoyingly can't get my <div> to center on that Error Page - http://www.ayrshireminis.com/400.htm ......

Picco

Apostropartheid
11-27-2007, 10:58 PM
just set up a PHP page and send the error using the header function.


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

If you've set up your .htaccess right, it should redirect you to your ErrorDocument.

I've not actually done it before, but it's how you do it with HTTP 400, so is worth a shot.

crmpicco
11-27-2007, 11:27 PM
ok, that's great. I created a page that has just that code in it www.ayrshireminis.com/400test.php

After googling for the "No input file selected" error I get I found I should enter three lines in my .htaccess file, my .htaccess file now 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
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule ^.+.php$ /bogusfile


This does not work, if I change /bogusfile to /400.htm it works, but that's not using my 400.shtml file???

Picco

Apostropartheid
11-28-2007, 05:22 PM
Then why don't you set it to /400.shtml then? -.- Where is that file, anyway? I can't find it.

BTW, 404 on your test.

crmpicco
11-28-2007, 08:08 PM
i tried setting it to 400.shtml, but it just gave me a 404. Problem is I don't want to set it to 400.shtml, I want it to detect a 400 error and show the 400 error page, same for a 404 error.

i don't know where in the following lines it says that it pertains to a 400 error:



RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule ^.+.php$ /bogusfile

Apostropartheid
11-28-2007, 08:17 PM
Why don't you just use .html or .php? There's no need for includes here, as it's a standalone page.

You shouldn't be using rewrite? You're using an ErrorDocument to handle the error, so the code should be

ErrorDocument 400 http://www.ayrshireminis.com/400.shtml
which is similar to the 404 one, which is
ErrorDocument 404 http://www.ayrshireminis.com/404.shtml

crmpicco
11-28-2007, 08:26 PM
took those three lines out and replaced it with the ErrorDocument line you provide, but if you go to: http://www.ayrshireminis.com/400test.php you'll just get a 'No input file specified.' error.....

This is 400.shtml


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


and this is 400.htm:



<!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:info@ayrshireminis.com?Subject=400 Error" style="color: #FFFFFF; font-weight: bold;">info [ AT ] ayrshireminis [ DOT ] com</a>
<br><br><br>
</div>
</BODY>
</HTML>


any ideas why i'd get that error?

Apostropartheid
11-28-2007, 08:34 PM
You've done something really weird to your .htaccess...404 just ignores everything and displays its 404, but Firefox comes up with a lot of stuff about directives. Try taking everything out and stick it into a file, and then try?

crmpicco
11-28-2007, 08:45 PM
Sorry mate, I gave you the wrong URL. The URL for that test script is http://www.ayrshireminis.com/mini/400test.php - try that......nothing???

this is my entire .htacess file right now:



# -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

crmpicco
11-28-2007, 08:49 PM
how do you mean taking everything out?

Apostropartheid
11-28-2007, 08:50 PM
Just take it out, everything, apart from the ErrorDocument line. Then try it. Replace it afterwards.

crmpicco
11-28-2007, 10:53 PM
No, nothing......took EVERYTHING out the htaccess file except the ErrorDocument line. Also tried taking the ErrorDocument line out then refreshing. :-(

http://www.ayrshireminis.com/mini/400test.php

I would have thought when I created a *.shtml document in my Control Panel on the server it would have amended my .htaccess file to have the ErrorDocument line in it.

Any other ideas as to what this isn't showing?

crmpicco
11-28-2007, 10:54 PM
also.....just added in another line:



ErrorDocument 404 http://www.ayrshireminis.com/404.shtml


so surely going to a non-existent URL should fire up that Error Doc?

Picco

:-)

crmpicco
11-28-2007, 11:14 PM
the lines in my now working .htaccess file:


ErrorDocument 400 /400.shtml
ErrorDocument 401 /401.shtml
ErrorDocument 403 /403.shtml
ErrorDocument 404 /404.shtml
ErrorDocument 500 /500.shtml


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

quick way to test a 500 I.S.E?

Picco

crmpicco
11-29-2007, 10:46 PM
have been advised to add these three lines to my .htaccess file:


Options +FollowSymLinks
RewriteEngine On
RewriteRule ^abc /abc [QSA,L]


which....to be fair does throw a 500 error when i go to www.ayrshireminis.com/abc

but suppose i'll need to wait until I get an actual runtime error in my scripting to get a true 500.

Cheers again,
Picco

Apostropartheid
11-30-2007, 05:21 PM
1) I think HTTP 400 is handled by the browser rather than the server. IE chucks up its own page. Firefox is rather unhelpfully blank.
2) Again...
<?
header("HTTP/1.1 500 Internal Service Error");
header("Status: 500 Internal Service Error");
?>
3) /400test.php still doesn't exist.

crmpicco
12-10-2007, 09:51 PM
sorry I was giving you the wrong URL along for that 400test.php :-)

Are you sure throwing a 500 error in the header of a document is enough for the server to throw a true 500 error message?

Picco

Apostropartheid
12-11-2007, 04:46 PM
Yep, in the same way the setting your Content-Type header in PHP to application/xhtml+xml will result in a true XHTML document MIME.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum