[Mediawiki-l] 404 handling to shorten urls, header 200 OK doesn't work

Sylvain Machefert iubito at gmail.com
Fri Jul 14 12:32:50 UTC 2006


Hi !

I've changed my "404 handling" to shorten my URLs.

If you call http://tousauxbalkans.jexiste.fr/Agenda the page displays in the
browser, but if I look the header, using a downloader (httrack,
nettransport...), I get this :

2006-07-14 14:13:27.765 Connecting to tousauxbalkans.jexiste.fr:80
2006-07-14 14:13:27.859 Connecting to 84.207.24.9:80
2006-07-14 14:13:27.953 Connected
2006-07-14 14:13:27.953 GET /Agenda HTTP/1.1
2006-07-14 14:13:27.953 Host: tousauxbalkans.jexiste.fr
2006-07-14 14:13:27.953 Cookie:
tousauxbalkans_wiki__session=4c3m8g5rc1bata9427cs3cvid2;
tousauxbalkans_wiki_UserID=1; tousauxbalkans_wiki_UserName=Iubito;
tousauxbalkans_wiki_Token=100B814B9E1E60E57FBF45BF33C45428
2006-07-14 14:13:27.953 Accept: */*
2006-07-14 14:13:27.953 User-Agent: Mozilla/4.0 (compatible; MSIE 5.00;
Windows 98)
2006-07-14 14:13:27.968 Connection: Keep-Alive
2006-07-14 14:13:30.250 HTTP/1.1 404 Not Found
2006-07-14 14:13:30.250 Date: Fri, 14 Jul 2006 12:08:16 GMT
2006-07-14 14:13:30.250 Server: Apache/1.3.33 (Debian GNU/Linux)
mod_tsunami/3.0 mod_layout/3.2.1
2006-07-14 14:13:30.250 Cache-Control: private, must-revalidate, max-age=0
2006-07-14 14:13:30.265 Content-language: fr
2006-07-14 14:13:30.265 ETag:
W/"tousauxbalkans:pcache:idhash:2842-0!1!0!2!!fr!2--20060714065302"
2006-07-14 14:13:30.265 Expires: Thu, 01 Jan 1970 00:00:00 GMT
2006-07-14 14:13:30.265 Vary: Accept-Encoding,Cookie
2006-07-14 14:13:30.281 X-Powered-By: PHP/5.1.2-1.1
2006-07-14 14:13:30.281 Set-Cookie:
tousauxbalkans_wiki__session=4c3m8g5rc1bata9427cs3cvid2; path=/
2006-07-14 14:13:30.281 Last-Modified: Fri, 14 Jul 2006 11:46:00 GMT
2006-07-14 14:13:30.281 Connection: close
2006-07-14 14:13:30.296 Transfer-Encoding: chunked
2006-07-14 14:13:30.296 Content-Type: text/html; charset=utf-8
2006-07-14 14:13:30.296 HTTP Error

and the downloader doesn't continue because it receive a HTTP/1.1 404 Not
Found

My .htaccess simply contains the following instruction :
ErrorDocument 404 /404.php5

In 404.php5, I include index.php that's why the browser get the page.
Even if I set header 200 OK, it receive a 404 not found.

Here is my 404.php5 code :
<?php
header('HTTP/1.1 200 OK');
$title = substr(getenv('REQUEST_URI'), 1);
$title = str_replace('index.php?title=', '', $title);
$title = str_replace('index.php5?title=', '', $title);
$_GET['title'] = urldecode($title);
$_POST['title'] = urldecode($title);
$_REQUEST['title'] = urldecode($title);
include('index.php5');
?>

If I replace the include by a redirect, I receive a 302, a redirect to
index.php5 and then a 200.
header("Location: index.php5?title='.$title);
2006-07-14 14:30:25.359 Connecting to tousauxbalkans.jexiste.fr:80
2006-07-14 14:30:25.437 Connecting to 84.207.24.9:80
2006-07-14 14:30:25.546 Connected
2006-07-14 14:30:25.546 GET /Agenda HTTP/1.1
2006-07-14 14:30:25.546 Host: tousauxbalkans.jexiste.fr
2006-07-14 14:30:25.546 Cookie:
tousauxbalkans_wiki__session=4c3m8g5rc1bata9427cs3cvid2;
tousauxbalkans_wiki_UserID=1; tousauxbalkans_wiki_UserName=Iubito;
tousauxbalkans_wiki_Token=100B814B9E1E60E57FBF45BF33C45428
2006-07-14 14:30:25.546 Accept: */*
2006-07-14 14:30:25.546 User-Agent: Mozilla/4.0 (compatible; MSIE 5.00;
Windows 98)
2006-07-14 14:30:25.562 Connection: Keep-Alive
2006-07-14 14:30:25.921 HTTP/1.1 302
2006-07-14 14:30:25.921 Date: Fri, 14 Jul 2006 12:25:13 GMT
2006-07-14 14:30:25.921 Server: Apache/1.3.33 (Debian GNU/Linux)
mod_tsunami/3.0 mod_layout/3.2.1
2006-07-14 14:30:25.921 X-Powered-By: PHP/5.1.2-1.1
2006-07-14 14:30:25.937 Location: index.php5?title=Agenda
2006-07-14 14:30:25.937 Connection: close
2006-07-14 14:30:25.937 Transfer-Encoding: chunked
2006-07-14 14:30:25.937 Content-Type: text/html
2006-07-14 14:30:25.953 Redirect to
http://tousauxbalkans.jexiste.fr/index.php5?title=Agenda
2006-07-14 14:30:25.953 Connecting to tousauxbalkans.jexiste.fr:80
2006-07-14 14:30:25.968 Connecting to 84.207.24.9:80
2006-07-14 14:30:26.062 Connected
2006-07-14 14:30:26.062 GET /index.php5?title=Agenda HTTP/1.1
2006-07-14 14:30:26.062 Host: tousauxbalkans.jexiste.fr
2006-07-14 14:30:26.062 Cookie:
tousauxbalkans_wiki__session=4c3m8g5rc1bata9427cs3cvid2;
tousauxbalkans_wiki_UserID=1; tousauxbalkans_wiki_UserName=Iubito;
tousauxbalkans_wiki_Token=100B814B9E1E60E57FBF45BF33C45428
2006-07-14 14:30:26.062 Accept: */*
2006-07-14 14:30:26.078 User-Agent: Mozilla/4.0 (compatible; MSIE 5.00;
Windows 98)
2006-07-14 14:30:26.078 Connection: Keep-Alive
2006-07-14 14:30:26.718 HTTP/1.1 200 OK
2006-07-14 14:30:26.718 Date: Fri, 14 Jul 2006 12:25:14 GMT
2006-07-14 14:30:26.718 Server: Apache/1.3.33 (Debian GNU/Linux)
mod_tsunami/3.0 mod_layout/3.2.1
2006-07-14 14:30:26.718 Cache-Control: private, must-revalidate, max-age=0
2006-07-14 14:30:26.734 Content-language: fr
2006-07-14 14:30:26.734 ETag:
W/"tousauxbalkans:pcache:idhash:2842-0!1!0!2!!fr!2--20060714065302"
2006-07-14 14:30:26.734 Expires: Thu, 01 Jan 1970 00:00:00 GMT
2006-07-14 14:30:26.734 Vary: Accept-Encoding,Cookie
2006-07-14 14:30:26.750 X-Powered-By: PHP/5.1.2-1.1
2006-07-14 14:30:26.750 Set-Cookie:
tousauxbalkans_wiki__session=4c3m8g5rc1bata9427cs3cvid2; path=/
2006-07-14 14:30:26.765 Last-Modified: Fri, 14 Jul 2006 11:46:00 GMT
2006-07-14 14:30:26.765 Connection: close
2006-07-14 14:30:26.765 Transfer-Encoding: chunked
2006-07-14 14:30:26.765 Content-Type: text/html; charset=utf-8
2006-07-14 14:30:26.781 Receiving datas
2006-07-14 14:30:26.890 Finish At 14181
2006-07-14 14:30:26.906 Download finished.

How do you explain in the first case I get a 404 error in 3 seconds, and in
the other case a 302 really quickly, whereas my .htaccess didn't changed,
and I never send header("HTTP/1.1 404 Not Found") in my code ?

--
Sylvain
http://iubito.free.fr
http://tousauxbalkans.jexiste.fr



More information about the MediaWiki-l mailing list