SMF Support > MyBB
How to keep URLs working after converting?
(1/1)
guidance:
I want to convert my MyBB forum to SMF, but want the links to keep working.
Like, if:
old MyBB link: ttp://site.com/thread101.php
new SMF link: ttp://site.com/smfthread101.php
I want the old MyBB links to redirect the new SMF links.
Oldiesmann:
If you only want to keep the topic URLs (and not worry about the URLs to the individual boards), create a file called "showthread.php" with the following code and stick it in your old MyBB directory. Just change the "http://www.site.com/smf" part to the actual URL of your forum. Note that this does not handle rewritten MyBB URLs (so if you had rewritten URLs enabled, you'll have to get someone to write the rewrite rules for you).
--- Code: ---<?php
if (!empty($_GET['pid']))
{
// Jump to a specific post
$pid = (int) $_GET['pid'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.site.com/smf/index.php?msg=' . $pid);
}
elseif (!empty($_GET['tid']) && (empty($_GET['action']) || $_GET['action'] == 'lastpost'))
{
$tid = (int) $_GET['tid'];
// SMF defaults to 20 posts per page in a topic; MyBB defaults to 10
$page = empty($_GET['page']) ? 0 : (((int) $_GET['page']) / 2);
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.site.com/smf/index.php?topic=' . $tid . '.' . $page);
}
else
{
$action = ($action == 'nextoldest') ? 'prev' : 'next';
$tid = (int) $_GET['tid'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.site.com/smf/index.php?topic=' . $tid . '.0;prev_next=' . $action . '#new');
}
?>
--- End code ---
That will handle most topic URLs:
.../showthread.php?tid=x&pid=Y#pidY - jump to a specific post
.../showthread.php?tid=x - first page of topic
.../showthread.php?tid=x&page=y - specific page within the topic
.../showthread.php?tid=x&action=nextoldest - jump to next oldest topic
.../showthread.php?tid=x&action=nextnewest - jump to next newest topic
It also adjusts for the difference in the default value for "posts per page" between MyBB and SMF - MyBB defaults to 10 posts per page, while SMF defaults to 20. If you've changed SMF to display something other than 20 posts per page, let me know what you've set it at and I'll adjust the code above.
Navigation
[0] Message Index
Go to full version