Custom 404 Error Handler

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Custom 404 Error Handler

Postby guillopuyol » 29. April 2009 20:42

Hello,

I am testing a new website and it is the first time I use XAMPP to avoid testing in a "live" environment.

I need to set a custom error handler to catch 404 errors and execute a PHP file.

I created a .htaccess file and I put it in the folder where the 404 errors should be treated differently

Code: Select all
ErrorDocument 404 /404handler.php


This did not work.

I tried changing the apache/conf/extra/httpd-multilang-errordoc.conf file to refference a php handler and this didn't work either.

It appears as if the multi-language errors are not working, because the 404 error I get is formatted differently than the english version of the 404 error page in the multi language error documents.

It looks like this:

Not Found
The requested URL /www/mywebsite/myfolder/notexistingfile was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


--------------------------------------------------------------------------------

Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9 Server at 127.0.0.1 Port 80



Your help will be greatly appreciated.
guillopuyol
 
Posts: 3
Joined: 29. April 2009 20:31

Re: Custom 404 Error Handler

Postby Wiedmann » 29. April 2009 20:49

I created a .htaccess file and I put it in the folder where the 404 errors should be treated differently
Code: Select all
ErrorDocument 404 /404handler.php

This did not work.

Are .htaccess files allowed in this folder?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Custom 404 Error Handler

Postby guillopuyol » 29. April 2009 21:09

I don't know if .htaccess are allowed in the folder... I don't know how to check that.

I have tried moving the whole thing out of that folder in public_html both .htaccess file and the 404handler.php and I still get the same error.

Something that is confusing is the second line of the error
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
as it would indicate (to me) that it didn't find the 404handler.php file.

I tried a couple more things: I removed the leading slash before /404handler.php in the .htaccess file and when I go to a file or folder that doesn't exist I see
404handler.php
on the screen. That would also indicate to me that the .htaccess file is being read but the 404handler.php is not executed.

I am going mad!

Thanks for your answers and time,

G
guillopuyol
 
Posts: 3
Joined: 29. April 2009 20:31

Re: Custom 404 Error Handler

Postby Wiedmann » 29. April 2009 21:11

I have tried moving the whole thing out of that folder in public_html

You are not using a XAMPP for Windows?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Custom 404 Error Handler

Postby guillopuyol » 29. April 2009 21:38

Yes I am... public_html is a folder I created to make it easier later to upload the whole thing to my server.

The fact that I am not seeing the 404 page in the multilanguage format makes me think something else is serving that 404 page... any idea of what could it be?

THanks
guillopuyol
 
Posts: 3
Joined: 29. April 2009 20:31

Re: Custom 404 Error Handler

Postby Wiedmann » 29. April 2009 21:46

The fact that I am not seeing the 404 page in the multilanguage format

You mean, without your ".htaccess", you can't see the default multilanguage 404 error page?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 63 guests