article.php from geeklog

|
Most of my presence on the net are links to articles and howtos I've written. The majority of my blog history was with geeklog. I migrated all my geeklog stories into wordpress stories with SQL. Now I'm on wordpress and the URLS don't match. I made a quick mapping script to handle old article references.
The problem is that geeklog story references were like this.
https://jimweller.net/article.php?story=20030905234919396

  or

https://jimweller.net/article.php?sid=20030905234919396
They used article.php and a generated story id number. Wordpress stories are called posts and the main index.php page can fetch them. Plus, wordpress can use permalinks. So, it has URLS like this.
https://jimweller.net/?p=32

  or

https://jimweller.net/index.php?p=32

  or

https://jimweller.net/2003/04/05/32
So, I did a join between the two story databases, gl_stories and wp_posts. That gave me a map from gl_stores.sid to wp_posts.id. I used some search&replace text editing to carve that map into a php array. Then wrote a quick chunk of redirect code at the end. It works champ.

< ?php

$story2postMap = array('20020509145922'=>'1',
'20010924101840'=>'2',
'20010927123304'=>'3',
[...]
'20040716121902711'=>'216');

if( isset( $_GET['sid'] ) ){
	header("Location: https://jimweller.net/?p=" . $story2postMap{$_GET['sid']} );
}
else if (  isset( $_GET['story'] ) ){
	header("Location: https://jimweller.net/?p=" . $story2postMap{$_GET['story']} );
}
else{
	header("Location: https://jimweller.net" );
} 
?>
It's not fancy, but it doesn't need to be since it's a one time deal for stories that used to be hosted in geeklog. This makes it so old links to my site are still valid. I was just shuttling all links to article.php to the main page which can totally confuse you when you're trying to follow a trail of information.