Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've edited my .htaccess file to the following :

ErrorDocument 404 /index.php?page=page-not-found
ErrorDocument 400 /index.php?page=bad-request

Now the error 404 redirects correctly, yet if i enter an address like http://newshell/%22%%5E$%%5E&%C2%A3& the server doesn't redirect the 400 error, but displays the default apache message. What am I doing wrong?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Quotation from Apache documentation:

Although most error messages can be overriden, there are certain circumstances where the internal messages are used regardless of the setting of ErrorDocument. In particular, if a malformed request is detected, normal request processing will be immediately halted and the internal error message returned. This is necessary to guard against security problems caused by bad requests.

So, if you want redirect error 400 you should uncomment ErrorDocument directive in httpd.conf Apache configuration file as follows:

# Some examples:
#ErrorDocument 500 http://foo.example.com/cgi-bin/tester
ErrorDocument 400 /cgi-bin/bad_request.pl
#ErrorDocument 401 /subscription_info.html
#ErrorDocument 403 "Sorry can't allow you access today" 

and restart Apache server.

share|improve this answer
    
And don't forget to replace /cgi-bin/bad_request.pl listed above to your error page =) –  Ivan Chuchman Jul 7 '10 at 11:38
    
thanks a ton...spent a whole day trying to find the cause :( –  Pushpesh Sep 4 '13 at 15:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.