homepage Welcome to WebmasterWorld Guest from 54.237.122.241
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Return 404 instead of 403
lixy




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

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?

 

hakre




msg:3631047
 6:58 pm on Apr 20, 2008 (gmt 0)

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?

jdMorgan




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

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]

hakre




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

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.

jdMorgan




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

> 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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved