Simple Machines Community Forum

SMF Support => Converting to SMF => Topic started by: Belford on February 18, 2012, 06:09:32 AM

Title: Old URLs after migration
Post by: Belford on February 18, 2012, 06:09:32 AM
Hello!

Is there a relatively fast method, which would redirect about 50 thousand results associated with the old script forum for those associated with the SMF?

You know, that link are quite different, and updating the results of the search will take a long time.

What did you do in a similar situation?

Title: Re: Old URLs after migration
Post by: ThorstenE on February 18, 2012, 06:14:22 AM
depends on the source forum, respective the old URLs, you might wanna check:
http://www.simplemachines.org/community/index.php?topic=170959.msg1090792#msg1090792
Title: Re: Old URLs after migration
Post by: Oldiesmann on February 18, 2012, 03:14:06 PM
Which forum system did you convert from?
Title: Re: Old URLs after migration
Post by: Belford on February 21, 2012, 10:45:33 AM
From phpBB 2.

@TE
Thanks for your reply, but what with subdomains?
I mean it will redirect example.com/community correctly, but how to prepare .htaccess document which can do the same for community.example.com? Now it will change last one for community.example.com/community what does nothing.
Title: Re: Old URLs after migration
Post by: Belford on March 04, 2012, 01:39:08 PM
Still the same problem + links (how to change http://www.example.com/printview.php? on http://www.example.com/viewtopic.php?

My code is based on
http://www.simplemachines.org/community/index.php?topic=170959.msg2455774#msg2455774
Title: Re: Old URLs after migration
Post by: Oldiesmann on March 05, 2012, 12:27:00 PM
The easiest way to do it is to just create "dummy" files - files with the same name as ones in phpBB which simply serve to redirect to the proper SMF URL.

Put these files in the phpBB directory and change them to match your setup (eg "http://www.example.com/smf" would be replaced with the actual URL to your SMF installation).

printview.php:
<?php
if (!empty($_GET['t']))
{
    
$topic = (int) $_GET['t'];
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: http://www.example.com/smf/index.php?action=printpage;topic=' $topic);
}
?>


viewforum.php:
<?php
$start 
= empty($_GET['start']) ? : (int) $_GET['start'];
if(!empty(
$_GET['f']))
{
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: http://www.example.com/smf/index.php?board=' . (int) $_GET['f'] . '.' $start);
}
?>


viewtopic.php:
<?php
$post 
= empty($_GET['p']) ? (int) $_GET['p'] : 0;
// Jumping to a specific post?
if (!empty($post))
{
    
$location 'msg=' $post;
}
elseif (!empty(
$_GET['t']))
{
    
$start = empty($_GET['start']) ? : (int) $_GET['start'];
    
$location 'topic=' . (int) $_GET['t'] . '.' $start;
}

header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com/smf/index.php?' $location);
?>


Change http://www.example.com/smf to the actual URL for your forum, and place these files in your phpBB directory, overwriting the existing ones.