|Custom 404 status code help|
| 5:07 pm on Mar 1, 2011 (gmt 0)|
I have done a lot of reading on this issue but can not seem to fix my problem.
The problem is that my custom 404 page does not seem to return headings correctly. In google webmaster tools it is showing me that I have soft 404's.
I'm not sure if this is something incorrect I have in my .htaccess file or the 404 page itself.
I have tried to set a forced 404 heading but it does not work.
here is an example of the custom error page being tested.
when i try and access a page that is not on my website i get this heading return from a header checker:
#1 Server Response: example.com/asdfsdvas/asdvsa
HTTP/1.1 302 Found
Date: Tue, 01 Mar 2011 16:56:07 GMT
Server: Apache/1.3.41 (Unix) mod_gzip/188.8.131.52a PHP/5.2.12 mod_ssl/2.8.31 OpenSSL/0.9.8e
Set-Cookie: PHPSESSID=458dc58b87e03eecab328379488fb037; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Status: 404 Not Found
that looks incorrect to me as I see it says 302 found at the top of the page. Is there a problem with this setup or is it ok to return these for a custom 404 page?
| 6:26 pm on Mar 1, 2011 (gmt 0)|
Not sure how you blast out your 404.php, but to really find out what is going wrong, you might want to start at the bottom:
1st: what is the ErrorDocument in your Apache conf file? There should be a general entry like
ErrorDocument 404 /404.php
then (if that fits), we look at the next step - which would be your .htaccess file...
There could be a general RewriteCondition that fits for ALL requests not found. These rules can be tricky. Make 300% sure that none of your rewrites is matching "anything but found"
3rd and last step of bugfixing is the 404.php - which should be a simple check for the header commands there!
If that does not help, fly another round over your access_log AND the error_log and look, what Apache writes there.
Then you should be able to find the bugger!
| 6:27 pm on Mar 1, 2011 (gmt 0)|
Turn the custom error documents off in your control panel if you have it set to on, then set it manually:
In Your .htaccess:
ErrorDocument 404 /404.php
At the top of 404.php
<?php header('HTTP/1.1 404 Not Found'); ?>
NOTE: When you are working with .htaccess files you MUST use a plain text editor, like NotePad, not Word or your file will not work. It will actually break your site if it's not saved correctly.
For more info, I recommend the Apache Forum [webmasterworld.com]
| 10:23 pm on Mar 1, 2011 (gmt 0)|
|There could be a general RewriteCondition that fits for ALL requests not found. These rules can be tricky. Make 300% sure that none of your rewrites is matching "anything but found" |
I think this could be the problem but i don't know what one of these rewrite conditions might look like.
does anyone have an example i can search my htaccess for to see if the problem is that?
[edited by: Robert_Charlton at 10:28 pm (utc) on Mar 1, 2011]
[edit reason] added quote formatting [/edit]
| 10:59 pm on Mar 1, 2011 (gmt 0)|
Please, do take your Apache questions to our Apache forum - thanks. Webmasters use many different servers, so Apache details are best discussed there. You'll have the added benefit of some highly qualified eyes on any advice you're given.
| 11:11 pm on Mar 1, 2011 (gmt 0)|
If you include a domain name in the ErrorDocument directive it will return the incorrect 302 response - as documented and warned about in the Apache documentation.
ErrorDocument 404 /file.ext is what you need.