Welcome to WebmasterWorld Guest from 50.19.156.19

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Http response code 302 instead of 404

     

sam222

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.

g1smd

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

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

lucy24

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

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



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

phranque

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

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



http://httpd.apache.org/docs/current/mod/core.html#errordocument
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.

sam222

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



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

lucy24

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

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



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