Rewriting Geeklog Articles with Mod_Rewrite and a few edits.

Friday, August 27 2004 @ 06:20 PM EDT

Contributed by: geeklogdir

The age old problem with Geeklog has always been to get your geeklog articles indexed and indexed well in search engines, particularly google.



The crux of the problem always lay with the long digit unix timestamp being included in a dynamic url format. (ie with a question mark). Google will index properly stuff like "index.php?topic=yourtopic", but the long digit timestamp in conjunction with "article.php?story=" has always been treated with suspicion by gbot. Although these urls now do get crawled and indexed they never have green in the google toolbar, and never figure as well as an article that is rewritten with googles rules in mind.



I have sought to find the easiest ways to rewrite the articles in a way that google does like. You will see i rewrite articles in the format /unixtimestamp.htm. Google likes the format, gbot believes the url represents a static .htm document, and in time, gives it green in the tool bar. This means that google thinks highly of the article and is likely to follow with authority any links within the htm doc it is reading.



When it comes down to it, its very easy to rewrite geeklog articles into .htm (can be any extension, ie .html, .php etc..)



lib-common.php


changing '/article.php?story=' . $A['sid'] . '
into '/' . $A['sid'] . '.htm' . '


on line 445


on line 448


on line 457


on line 2935



stats.php


changing $stat_templates->set_var('item_url', 'article.php?story=' . $A['sid']);
into $stat_templates->set_var('item_url', $A['sid'] . '.htm');


on line 165, there are a couple of identical lines that will need editing in the same way further down stats.php.



search.php


changing "article.php?story=' . $A['sid'] . '
into "' . $A['sid'] . '.htm' . '


on line 447


Note that newer versions of GL use search.class.php in system/classes/ and the edits need to be in there instead of search.php.... ie line 301.




users.php


Change $_CONF['site_url'] . '/article.php?story=' . $C['sid'] . '">'); into


$_CONF['site_url'] . '/' . $C['sid'] . '.htm' . '">');


On line 151



printable.thtml in your layout


changing "http://www.gldir.com/article.php?story=20040823161154250">http://www.gldir.com/article.php?story=20040823161154250
into
"http://www.gldir.com/20040823161154250.htm">http://www.gldir.com/20040823161154250.htm


on line 21



rewriting in these places should eliminate all mention of "article.php?story=" and adds an extension to the articles. Please note that you could go mad and rewrite absolutly everything within geeklog, but i don't think its worth the effort, because geeklogs only big weakness as regards to google has been the unixstamp expressed as a dynamic url.





I also added these lines to my .htaccess


RewriteEngine on


RewriteRule ^(.*).htm$ /article.php?story=$1 [NC,L]


This rule makes everything work.



There are on reflection many slight differences between various versions of geeklog and line numbers may be different as well, but as long as search for "article.php?story=" you should find all the right lines to edit.



As of September 2004 i have created a total Mod_Rewrite Version of geeklog 1.3.9.1.

Click Here for Mod Rewrite Geeklog



http://www.gldir.com/20040823161154250.htm