Page 1 of 2

Problem with static pages

Posted: Sat Aug 16, 2008 10:45 pm
by konus
I found out, that google doesn't like my static pages. I shows Error 404 not found for them. The same problem exists with XENU Link checker.

judebert suggested in this post:
judebert wrote:I understand that LiveHTTPHeaders extension for FireFox lets you see the headers. Perhaps you're getting a 404 along with the static page content. If so, we'd like to know why.
The extension reports really a 404 error:

Code: Select all

http://www.dd4kids.de/pages/kontakt.html

GET /pages/kontakt.html HTTP/1.1
Host: www.dd4kids.de
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.dd4kids.de/pages/termine.html
Cookie: web5_SID=90961f02a7ca74bb3b92f2ff29a258af; serendipity[karmaVote]=a%3A0%3A%7B%7D; serendipity[check]=1
Cache-Control: max-age=0

HTTP/1.x 404 Not Found
Date: Sat, 16 Aug 2008 20:22:05 GMT
Server: NOYB
...
I dont understand the output. Has anyone an idea where does it come frome?

Re: Problem with static pages

Posted: Mon Aug 18, 2008 12:44 pm
by garvinhicking
Hi!

The staticpage plugin should actually take care of sending a HTTP 200 header. The serendipity_event_staticpage.php file holds this code:

Code: Select all

      if ($this->selected()) {
            serendipity_header('HTTP/1.0 200');
            echo $this->parseStaticPage();
        }
you might want to change that to:

Code: Select all

      if ($this->selected()) {
            header('HTTP/1.0 200');
            echo $this->parseStaticPage();
        }
Then you might get a PHP error about that some content was emitted already, I suppose in one of your customized PHP files (a blank line or space or trailing UTF-8 characters), like a language file or plugin file. You must get rid of that output so that the staticpage plugin can properly emit the header...

HTH,
Garvin

Re: Problem with static pages

Posted: Mon Aug 18, 2008 10:37 pm
by konus
garvinhicking wrote:Hi!
you might want to change that to:

Code: Select all

      if ($this->selected()) {
            header('HTTP/1.0 200');
            echo $this->parseStaticPage();
        }
I have done that, but nothing much has changed. There was no error and the 404 is still there. I am not sure about caching, deleting browser cache did not help. So I will check back tomorrow.

If someone what to test, static pages are
http://www.dd4kids.de/pages/termine.html
http://www.dd4kids.de/pages/karte.html
http://www.dd4kids.de/pages/kontakt.html

Actually I don't know, what I have done. Is the code above supposed to be a workaround or is it kind of a debugging mode?

Greetings and thanks for the help!
Konrad

Re: Problem with static pages

Posted: Tue Aug 19, 2008 10:43 am
by garvinhicking
Hi!
I have done that, but nothing much has changed. There was no error and the 404 is still there. I am not sure about caching, deleting browser cache did not help. So I will check back tomorrow.
Hm, that is strange. Can you edit your s9y's index.php and find this code at around line 605:

Code: Select all

} else {
    $serendipity['view'] = '404';
    header('HTTP/1.0 404 Not found');
    include(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
    // printf('<div class="serendipity_msg_important">' . DOCUMENT_NOT_FOUND . '</div>', $uri);
}
and change that to:

Code: Select all

} else {
    $serendipity['view'] = '404';
    header('X-ORIG: HTTP/1.0 404 Not found');
    include(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
    // printf('<div class="serendipity_msg_important">' . DOCUMENT_NOT_FOUND . '</div>', $uri);
}
Usually, subsequent HTTP header calls later in the PHP code should overwrite the prior output. This does work in my environment, but in your case it seems that the staticpage plugin that comes after the code above is not able to indicate the "real" HTTP-Header to your server.

Who is your provider, which webserver and version do you use, which PHP version, and does it run as module or CGI?

Regards,
Garvin

Re: Problem with static pages

Posted: Thu Aug 21, 2008 11:00 am
by konus
Sorry for the delay.
garvinhicking wrote:Who is your provider, which webserver and version do you use, which PHP version, and does it run as module or CGI?
My hoster is http://www.sysprovide.de
the webserver should be an apache2 (any way to find out for sure?)
the PHP Version is 5.2.6
I think it runs as CGI/FastCGI
(phpinfo output on request by PM)

I will modificated the index.php, and will test it this evening. (I have no firefox at work.)

Greetings and thanks
konus

Re: Problem with static pages

Posted: Thu Aug 21, 2008 11:15 am
by garvinhicking
Hi!

We could also try to create a better testcase.

Create a directory "test" in your s9y tree. Create a .htacces in that directory:

Code: Select all

RewriteEngine Off
ErrorDocument 404 notfound.php
Now create a notfound.php file:

Code: Select all

<?php
header('HTTP/1.0 200');
header('HTTP/1.0 404 Not Found');
header('HTTP/1.0 200');
echo "Bla!";
Then call http://yourblog/test/pages/somefile.html -- this should invoke the notfound.php. Now inspect your headers via LiveHTTPheaders -- you should get a "HTTP 200" page, but I believe you might now get a 404.

Depending on the output we can try to modify the script to see what's actually happening. Maybe using this instead could already help:

Code: Select all

<?php
header('HTTP/1.0 200 OK');
header('HTTP/1.0 404 Not Found');
header('HTTP/1.0 200 OK');
echo "Bla!";
But it could also all be related to some Apache2 setting which might require us to work together with your hoster.

Regards,
Garvin

Posted: Thu Aug 21, 2008 11:24 am
by konus
A first test with the external service Web-sniffer.net brings Error 404 again.

OK your where faster, I will test the above now.

Posted: Thu Aug 21, 2008 11:26 am
by garvinhicking
Hi!
konus wrote:A first test with the external service Web-sniffer.net brings Error 404 again.
With both variants (once "200" and once "200 OK")?

Does it get 200 when you remove the one header(404) call?

Regards,
Garvin

Posted: Thu Aug 21, 2008 11:27 am
by garvinhicking
Hi!

Ah, one other thing: I think in the .htaccess you need to use "/test/notfound.php" and not only "notfound.php" -- the complete path to notfound.php needs to be used here.

Regards,
Garvin

Posted: Thu Aug 21, 2008 11:52 am
by konus
Ah, one other thing: I think in the .htaccess you need to use "/test/notfound.php" and not only "notfound.php" -- the complete path to notfound.php needs to be used here.
Yes, I found out already :P
With both variants (once "200" and once "200 OK")?
Does it get 200 when you remove the one header(404) call?
It reports 404 in every case, with ('HTTP/1.0 200'), with header('HTTP/1.0 200 OK') and without ('HTTP/1.0 404 Not Found')

The notfound.php lies in http: //www.dd4kids.de/test/notfound.php and at the moment, there is no ('HTTP/1.0 404 Not Found') Linie in it.
Web-sniffer.net reports 404. (I hope this webservice is relayable).

Posted: Thu Aug 21, 2008 12:07 pm
by konus
An another idea, I found out, how to enable the error.log.
I found 3 warnings and one error:
[warn] mod_fcgid: stderr: PHP Warning: Cannot use a scalar value as an array in /var/www/web5/html/serendipity/plugins/serendipity_event_karma/serendipity_event_karma.php on line 1142
[warn] mod_fcgid: stderr: PHP Warning: Cannot use a scalar value as an array in /var/www/web5/html/serendipity/plugins/serendipity_event_karma/serendipity_event_karma.php on line 1143
[error] [client 89.246.171.87] File does not exist: /var/www/web5/html/serendipity/pages
edit, one more warning:
[warn] mod_fcgid: stderr: PHP Fatal error: Cannot redeclare class serendipity_event_geotag in /var/www/web5/html/serendipity/plugins/serendipity_event_geotag/serendipity_event_geotag_org.php on line 323

Posted: Thu Aug 21, 2008 1:40 pm
by garvinhicking
Hi!

Those warnings are currently unrelated. They can happen in certain cases if URLs are called that are not meant to be properly interrepeted, mostly from misbehaving search engines.

Please contact your provider and ask him, why the header('HTTP/1.0 200') call does not work on your server setup. According to the php.net/header documentation, it should work on all environments, but in your environment it simply does not seem to take effect. On all three servers I tried this today (one PHP5 module, one PHP4 cgi, one PHP5 fastcgi) my headers took effect with the same notfound.php I mentioned to you. So I believe there must be some configuration directive on your host that blocks these HTTP header calls.

Best regards,
Garvin

Posted: Thu Aug 21, 2008 5:49 pm
by konus
I am still in contact with my hoster. But I would like to come back to the test enviroment.
In the htaccess is the notfound.php declared.
In the notfound.php are:

Code: Select all

<?php 
header('HTTP/1.0 200'); 
header('HTTP/1.0 404 Not Found'); 
header('HTTP/1.0 200'); 
echo "Bla!";
I tested it on a other webserver (Schlund/1&1) as well and got the same 404 results for all noexisting files (beside the notfound.php itself). I expected it to work like you said, but it doesn't :shock:

Posted: Thu Aug 21, 2008 5:50 pm
by konus
konus wrote:I am still in contact with my hoster (he did not find anything out by now). But I would like to come back to the test enviroment.
In the htaccess is the notfound.php declared.
In the notfound.php are:

Code: Select all

<?php 
header('HTTP/1.0 200'); 
header('HTTP/1.0 404 Not Found'); 
header('HTTP/1.0 200'); 
echo "Bla!";
I tested it on a other webserver (Schlund/1&1) as well and got the same 404 results for all noexisting files (beside the notfound.php itself). I expected it to work like you said, but it doesn't :shock:

Posted: Thu Aug 21, 2008 6:21 pm
by garvinhicking
Hi!

How does your .htaccess look like currently, does it properly specify the full HTTP path? Do you get the "Bla!" output despite of the 404 content properly?

Regards,
Garvin