This is a very simple redirection script, either download or copy below:
PHP:
<?php
$startTime = microtime(true);
$fileDir = dirname(__FILE__);
require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');
XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);
####################
// GET DB
$db = XenForo_Application::get('db');
$_REQUEST['slug'] = (isset($_REQUEST['slug']) ? $_REQUEST['slug'] : '');
$id = $db->fetchOne("
SELECT id
FROM mybb_google_seo
WHERE url = ?
AND active = 1
AND idtype = 3
", $_REQUEST['slug']);
if ($id)
{
header ('HTTP/1.1 301 Moved Permanently');
header ('Location: http://yoursite.com/forums/' . $id);
}