logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Changing the "status code" of responses
Author
zckzck



Joined: 27 Jun 2007
Posts: 2

PostPosted: Wed 27 Jun '07 12:07    Post subject: Changing the "status code" of responses Reply with quote

Hi,
I've been trying to change the status-code of responses sent by the server for quite some time now, but haven't been successful.

I want my Apache server to serve a 200 status code, instead of, for example 500 or 403 responses.

I know that I can manipulate the custom error page, as is described here:
http://httpd.apache.org/docs/2.0/custom-error.html
but the status code stays the same.

How do I do this?

Thanks!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 27 Jun '07 14:00    Post subject: Reply with quote

200 comes every time when you call a normal page Wink
403 is only when it is forbidden ^^
500 you messed something up in your httpd.conf Mr. Green

http://localhost/icons/ should give a 200 Wink

Custom Error Response means only that you can create an own error page

e.g.
Code:

 ErrorDocument 404 /Lame_excuses/not_found.html
Back to top
tdonovan
Moderator


Joined: 17 Dec 2005
Posts: 611
Location: Milford, MA, USA

PostPosted: Wed 27 Jun '07 15:20    Post subject: Reply with quote

If the 403 or 500 status codes are generated by Apache - no, there is no way to directly change the status-code of Apache responses. Changing the custom error page does not change the status-code. These codes are built into Apache, and you would need to alter the Apache source code to change them.

If your reponses are from PHP (or from some other script or CGI module), then there usually is a way to control the status-codes. With PHP you can do this with the header function.

One (very kludgey) way to get a 200 status in two steps is to use the ErrorDocument directive with a full URL, like this:
Code:
ErrorDocument 403 http://www.myserver.com/myerrorpage.html

This will re-direct the browser (status 302) to myerrorpage.html on www.myserver.com, which will then be delivered with a normal 200 status-code.

Why would you want to change 403 and 500 status codes to 200? That doesn't seem like a very sensible thing to do.

-tom-
Back to top
zckzck



Joined: 27 Jun 2007
Posts: 2

PostPosted: Sun 01 Jul '07 8:46    Post subject: Reply with quote

Thanks tdonovan.

The reason I want to alter the status code of the responses is because somtimes the responses may reveal certain information that will help a hacker hack the server.
For example: If the directory "admin" exists but the hacker doesn't have access to it, he will see a 403 response, which will reveal that this directory really exists, while for the directory "asfasfzxbcasgwe" he will receive a 404 response code.
Now the hacker knows that this dir exists and may try to access it in other ways...
If the hacker will receive some other response code he wouldn't know that the directory exists.

Maybe this could be done through mod security?

Thanks.
Back to top


Reply to topic   Topic: Changing the "status code" of responses View previous topic :: View next topic
Post new topic   Forum Index -> Apache