homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Http response code 302 instead of 404

 1:34 pm on Aug 17, 2012 (gmt 0)

In .htaccess file I have code ErrorDocument 404 [example...] If page not found it is redirecting to this URL but server returns 302 response code instead of 404. Should it not return 404 code.



 6:38 pm on Aug 17, 2012 (gmt 0)

The Apache manual specifically warns that the ErrorDocument should be a local path and file and never specified with protocol or domain.


 9:37 pm on Aug 17, 2012 (gmt 0)

Time for a chorus of:

I really hate this ### machine
I wish that they would sell it
It never does just what I want
But only what I tell it.

It is returning a 302 because you've told it to.

No I haven't. I've just named an ErrorDocument.

Yes you have, because you've given the full protocol-and-path. That creates a redirect. ErrorDocument declarations have to be in the form

ErrorDocument {number} /{nameofdocument}

for example

ErrorDocument 404 /boilerplate/my404.html


 12:59 am on Aug 18, 2012 (gmt 0)

Note that when you specify an ErrorDocument that points to a remote URL (ie. anything with a method such as http in front of it), Apache HTTP Server will send a redirect to the client to tell it where to find the document, even if the document ends up being on the same server. This has several implications, the most important being that the client will not receive the original error status code, but instead will receive a redirect status code. This in turn can confuse web robots and other clients which try to determine if a URL is valid using the status code.


 1:28 am on Aug 18, 2012 (gmt 0)

I got it, it worked. Many thanks for replies and excellent support :-)


 1:48 am on Aug 18, 2012 (gmt 0)

I wish they hadn't included that last line. "Oh, good! I LIKE to confuse robots."

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