Forum Moderators: phranque
I have an .htaccess file that is supposed to serve a custom 404.
[quote]
ErrorDocument 404 http://www.example.com/missing.html
With this code, the site shows the appropriate 404 page. Except when I did a server header check, the server headers are producing a 302 found message instead of a 404.
Is that something badly configured on the server end, or have I somehow messed up something as simple as this one line of instruction.
Just for the record, the server does show 404 in the header if I remove the htaccess file.
any ideas?
I think it has something to being on a shared server? The main reason is that I don't want to serve Bots 302 responses when they are really 404s.
Is there anything that I can insert into the 404 document file to have the same effect - NoIndex, NoFollow for instance....
Or is there a better solution?
The problem is using the entire domain name is the only way that I can actually get the correct file to be served.
Do you mean the file is in the same domain, but specifying it as /missing.html doesn't work, or do you mean it has to be at a different domain? Is one domain http:// and one [,...] or a different port?
The way ErrorDocument works, it WILL give a 302 if the full url is given. Specifying a filename, WITH the path from the server root, should normally work, and that's what you want to aim at getting to work - 404 with a full url won't.
You mention being on a shared server - maybe you need to add further path information in the name to ensure it goes to your directory from the server root? For example if you're [widget.com...] then your error document might be /~patrick/missing.html etc?
The problem is that I am using the client's host to adminstrate a number of his domains so I don't exactly know much about the set up accept I have been given admin access.
When I use the htaccess file with a non-qualified url (not fully qualified URL), the server ignores the custom 404. The only way I can make it work is by using the entire domain.
I am guessing that this is something the webhost has to work out.
> something the webhost has to work out.
It certainly sounds like it... The solutions presented here are 100% correct, and Apache specifically warns about the 302 problem when using canonical URLs for 40x errors in the ErrorDocument documentation [httpd.apache.org].
Jim
I am guessing that this is something the webhost has to work out.
If it's a multi-domain virtual server then the setup can be unusual, so yes. You need to find out what prefix your missing.html needs to be reachable from the server root. It needs that prefix (e.g. /mydomain/missing.html or more) to work.
i had exactly the same error last night.
but mine worked with one virtual domain and didn't with the other!?*! ;)
(http://www.webmasterworld.com/forum92/498.htm)
i tried this morning and suddenly it worked perfectly. i did nothing to change it overnight (except dream about it a lot - subliminal persuasion? ;)
the only thing which occurs to me now is that is might have been an IE bug.
have you tried accessing your missing page with netscape or opera?