PDA

View Full Version : SMF and 404 script



djilou
Sat 4th Aug '07, 2:07pm
Hi

I use this code to do a 301 redirect from SMF's Urls to vBulletin


switch ($old_system)
{
case 'smf' :
$old_forum_script = "index.php?board=";
$old_thread_script = "index.php?topic=";
$old_post_script = "index.php?msg";
$old_user_script = "index.php?action=profile;u="; // Append userid
break;

default :
// No valid system entered
die('No valid system entered');
}

// It's for the old forum
if (strpos($_SERVER['REQUEST_URI'], "/{$old_folder}") === 0)
{
switch ($old_system)
{

case 'smf' :
if(preg_match('#index.php\?board=([0-9]+)#is', $_SERVER['REQUEST_URI'], $matches))
{
if (is_numeric($matches[1]))
{
$action = 'forum';
$sql = "SELECT forumid FROM {$tableprefix}forum WHERE importforumid=" . $matches[1];
}
}

// It's a thread link
if(preg_match('#index.php\?topic=([0-9]+)#is', $_SERVER['REQUEST_URI'], $matches))
{
if (is_numeric($matches[1]))
{
$action = 'thread';
$sql = "SELECT threadid FROM {$tableprefix}thread WHERE importthreadid=" . $matches[1];
}
}

// It's a post link
if(preg_match('#view=findpost\&p=([0-9]+)#is', $_SERVER['REQUEST_URI'], $matches))
{
if (is_numeric($matches[1]))
{
$action = 'post';
$sql = "SELECT postid FROM {$tableprefix}post WHERE importpostid=" . $matches[1];
}
}

// It's a user link
if(preg_match('#index.php\?action=profile;u=([0-9]+)#is', $_SERVER['REQUEST_URI'], $matches))
{
if (is_numeric($matches[1]))
{
$action = 'user';
$sql = "SELECT userid FROM {$tableprefix}user WHERE importuserid =" . $matches[1];
}
}
break;

default :
// No valid system entered
die('No valid system entered');
}

if (!$action)
{
$action = 'log';
}

}

now I need to edit this code to include urls like that:
http://www.site.com/smf/topic-t1.0.html

how can I do this?