Welcome to WebmasterWorld Guest from 54.204.210.197

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Return 404 instead of 403

   
3:05 pm on Apr 18, 2008 (gmt 0)

10+ Year Member



What I want to do is return a 404 status code for all 403s and I know this can be accomplished using PHP and the header() function but is there another way to accomplish this with Apache?
6:58 pm on Apr 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd like to know how to provoke a 404 error in apache as well right now. Currently I'm scanning the docs at htttpd.apache.org to find out more. First I thought mod_rewrite is capable of changing statuscodes but this seems to be for redirects only and 404 is not a redirect code.

Where did you start to look for it, which way of research have you thought of?

7:10 pm on Apr 20, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I don't know how to do this with PHP.

If you want to 'create' a conditional 404 with mod_rewrite, simply internally-rewrite the request to a non-existent URL-path. Or use the [G] flag on a rule to create a 410-Gone response for HTTP/1.1 clients (and later).

Jim

[edited by: jdMorgan at 7:11 pm (utc) on April 20, 2008]

5:39 am on Apr 21, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I read about G as well, but that is not 404 it is 410. In my case I'd like to prevent displaying a 403 (forbidden) so that no assumptions can be made about the directory structure.

The Idea to rewrite to non-existent files I had thought about as well but some errorpages do display the "true" filename of the file then.

The last thing I was working on is to manipulate environment vars sothat apache will display a 404. But I could not proof if this can be done or not.

12:08 pm on Apr 21, 2008 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



> The Idea to rewrite to non-existent files I had thought about as well but some errorpages do display the "true" filename of the file then.

That will only happen if you use an external redirect instead of a internal rewrite, or if you have a server configuration error that causes a redirect to occur on the request.

Jim