MyBB Community Forums

Full Version: redirect old phpbb links and page rank issues
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Hello
I am still doing convertion locally from phpbb3.0.7 to mybb
I have two questions:
- Does the merger script preserve forum, post and topic IDs, so that
/phpbb/topic8230.html ---> /mybb/thread-8230.html
/phpbb/topic1677.html#p28062 ---> /mybb/thread-1677-post-28062.html#pid28062
etc...

2- If so Ids are preserved, how to set a redirection so old phpbb links point to mybb ones ? I hope to preserve page ranks in Search engines?
No, it doesn't AFAIK
THanks for quick reply,thought it is sad to hear it Sad
Well, is there any way to redirect old phpbb links to the mybb search or index page for example?
I am talking about thousands of links spidered by google which are now pointing to nothing but to "Page Not found" !!!
It's possible to make the redirection, if you have not converted yet.

The merge system stores the old_id => new_id correlation during the merge. Only it removes this information once it's done merging. If you change the merge system to keep the info, you can write a small PHP script that redirects threads for you.

In convert/resources/functions.php, find

$drop_list = array(
    "users" => array('import_uid', 'import_usergroup', 'import_additionalgroups', 'import_displaygroup'),
    "forums" => array('import_fid', 'import_pid'),
    "threads" => array('import_tid', 'import_uid', 'import_poll'),
    "polls" => array('import_pid', 'import_tid'),
    "usergroups" => array('import_gid'),
    "privatemessages" => array('import_pmid'),
    "events" => array('import_eid'),
    "attachments" => array('import_aid'),
);

For threads redirection, you want to keep the import_tid for threads, so take import_tid out of the drop list for threads:

"threads" => array('import_uid', 'import_poll'),

Then in your forum main directory you write a small mergeredirect.php:

<?php
define("IN_MYBB", 1);
define("NO_ONLINE", 1);
require("global.php");

// Did we get an old thread id?
if($mybb->input['tid'])
{
    // See if we can get a new one.
    $import_tid = intval($mybb->input['tid']);
    $query = $db->simple_select("threads", "tid", "import_tid=${import_tid}");
    $result = $db->fetch_array($query);

    if($result)
    {
        // Redirect to the new thread URL...
        header("Location: ${settings['bburl']}/".get_thread_link($result['tid']), true, 301);
        exit;
    }
}

// By default, redirect back to index.
header("Location: ${settings['bburl']}", true, 301);
exit;
?>

Then in your .htaccess you add a rewrite rule that makes request for your old urls go to the mergeredirect.php

RewriteRule ^topic([0-9]+)\.html$ mergeredirect.php?tid=$1 [L]

After 4-8 weeks or so, consider removing the redirection and the import_tid field from the threads table.

Also, a Sitemap (Google SEO plugin) may help Google in picking up your new links.
@frostschutz
Thanks a lot
At least, now there is a hope to keep page rank from serach engines Smile
I am still doing convertion tests locally, so I will try your fix, and go back to you whith any feed back
cheers
Yeah, please tell me if it works. I never used the merge system so I haven't actually tested it. Toungue
Actually frostschultz's method works best if you use the old phpBB filename for it Toungue That way people not using the SEO Urls can get it with the old topics.php or whatever file as well.
@ Dylan M
Thanks for comment
I was using phpbb-seo, so does it mean frostschutz's method will not work for me?

@ frostschutz
where sould I put .htaccess? in domain root or in mybb root folder?
Usually in the MyBB folder. It depends on your setup though. If the old forum was in a different folder than the new one (as you described in your first post), then you'd need a .htaccess in the old folder that does a generic redirect to the new folder, and then a .htaccess in the new folder that takes over from there. This would mean two redirects instead of just one but that's fine as long as it works.
Wonderfull SmileSmile Thanks a lot
I putted one redirection only in domain root:
RewriteRule ^phpbb/topic([0-9]+)\.html$ /mybb/mergeredirect.php?tid=$1 [L]
As far I tested it , it is working like a charme !!!
So can I keep only this single redirection rule?
Two extra questions:
1- Is there any chance to get links like:phpbb/post24976.html redirected as well?
2- if not possible, what redirection rule to put into htaccess so any other old link, except topic[..].html, will be redirected to mybb search page?

Pages: 1 2 3 4