phpBB --> SMF Keep your Links.

Started by VidPro, July 14, 2006, 05:25:27 PM

Previous topic - Next topic

VidPro

I had run phpbb for over 7 years on many of my sites one of them having over 750k posts. I did not want all of the links to my phpbb forums and topics to be dead or broken so I came up with a little fix that I thought I would share incase there are others who do not want to all those broken or dead links.

you will need to create 3 new files to replace the old phpbb ones.

index.php
viewtopic.php
viewforum.php

here is what needs to be in the index.php file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset={S_CONTENT_ENCODING}">
<meta http-equiv="Content-Style-Type" content="text/css">
<META http-equiv="refresh" content="0;URL=http://www. your path to SMF /index.php">
</head>


be sure to set the URL and Path to match that of your site.

here is the viewforum.php:
<?
if ( isset($HTTP_GET_VARS['f']) || isset($HTTP_POST_VARS['f']) )
{
$forum_id = ( isset($HTTP_GET_VARS['f']) ) ? intval($HTTP_GET_VARS['f']) : intval($HTTP_POST_VARS['f']);
}
else if ( isset($HTTP_GET_VARS['forum']))
{
$forum_id = intval($HTTP_GET_VARS['forum']);
}
else
{
$forum_id = '0';
}

if ( isset($forum_id)){$send2forum = $forum_id;}
if ( isset($send2forum)){
$send2page = $send2forum;
if ($forum_id =='0'){
$send2dest = "index.php";
}
else{
$send2dest = "index.php/board,".$send2page.".0.html";
}
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset={S_CONTENT_ENCODING}">
<meta http-equiv="Content-Style-Type" content="text/css">
<META http-equiv="refresh" content="0;URL=http://www.URL & Path to your SMF/<?echo $send2dest ?>">
</head>


Here is the viewtopic.php:
<?
if ( isset($HTTP_GET_VARS['t']) )
{
$topic_id = intval($HTTP_GET_VARS['t']);
}
else if ( isset($HTTP_GET_VARS['topic']) )
{
$topic_id = intval($HTTP_GET_VARS['topic']);
}

if ( isset($topic_id)){$send2topic = $topic_id;}
if ( isset($send2topic)){
$send2page = $send2topic;
$send2dest = "index.php/topic,".$send2page.".0.html";}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset={S_CONTENT_ENCODING}">
<meta http-equiv="Content-Style-Type" content="text/css">
<META http-equiv="refresh" content="0;URL=http://www.URL & Path to your SMF/<?echo $send2dest ?>">
</head>


Be sure to set the URL and Path on all 3 files to point to your SMF installation. Then just log into your ftp server or how ever you wish to upload the files. Rename the old files on your server to a .old or .bak or whatever you like then upload the new ones.

Any visitor that clicks a link to your old phpbb forums like say /phpbb/viewtopic.php?t=543243 will be taken to that very same post on your smf forums and the same goes for your forums and the index page will send them to the new SMF board index. This is very handy if you have lots of links in your posts that point to your old phpbb forums.

Hope this helps some of you...

Kǝmac

Good idea, but using HTTP Redirect 301 would be better. Search engines will be informed about the move and (probably) Google will preserve PR. The same effect can be achieved using mod_rewrite.
[nofollow] - Polska Pomoc Simple Machines Forum [nofollow]

Yakuza

Very good for people without mod_rewrite :) Thanks
In all honesty, the past is the past and problems happen all the time. It's how we deal with it that's important. - Joseph Fung

English: Please don't ask for support on my mods in PM or MSN/ICQ, use the right board. Thank you.
Italiano: NON fornisco supporto tecnico via PM o MSN/ICQ, scrivete nel forum adatto e se posso aiutarvi rispondo con piacere.

taikahn

Explain how I would do this with mod-rewrite please?

sah62

Digging up an old thread because I just ran into the exact same problem...

In theory, adding this to your .htaccess file should work:

RewriteRule ^/forum/viewtopic\.php\?t=([0-9]+)$ /forum/index.php?topic=$1.0 [R=301,L]
RewriteRule ^/forum/viewforum\.php\?f=([0-9]+)$ /forum/index.php?board=$1.0 [R=301,L]


You might have to replace "forum" with whatever directory names you're using for your phpbb forum (in the pattern) and your SMF forum (in the result).  I don't yet have it working, though.  For some reason the rule isn't firing on my web server.  I'm trying to figure that out with my hosting company.

H

-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

sah62

I suspect that there will be a few minor changes to what I wrote above once I get it working.  Still no luck on that front, though.

sah62

#7
Woo hoo!  It's working thanks to help received in the Mod_Rewrite forum:

RewriteCond %{QUERY_STRING} ^(.*&)?t=([0-9]+)(&.*)?$ [NC]
RewriteRule ^forum/viewtopic\.php$ /forum/index.php?topic=%2.0 [R=301,L]

RewriteCond %{QUERY_STRING} ^(.*&)?f=([0-9]+)(&.*)?$ [NC]
RewriteRule ^forum/viewforum\.php$ /forum/index.php?board=%2.0 [R=301,L]


Here's a slight variation that might be needed if your site uses multiple domain names to reach the same pages.  With this variation the RewriteRule preserves the domain name received in the original query.

RewriteCond %{QUERY_STRING} ^(.*&)?t=([0-9]+)(&.*)?$ [NC]
RewriteRule ^forum/viewtopic\.php$ http://%{HTTP_HOST}/forum/index.php?topic=%2.0 [R=301,L]

RewriteCond %{QUERY_STRING} ^(.*&)?f=([0-9]+)(&.*)?$ [NC]
RewriteRule ^forum/viewforum\.php$ http://%{HTTP_HOST}/forum/index.php?board=%2.0 [R=301,L]

kizer

I tried the above and it just sent me to the front page of my new forum not to the topic its self. I as well tried to use mod_rewrite, but it looks like my server doesn't like it.
Own a Jeep? Links4Jeeps.com

kizer

Own a Jeep? Links4Jeeps.com

kizer

Ok, Im an idiot. It does work.

Has anybody worked on the profile? I have some articles that I wrote and so have others and I have a URL on each that says if you have any more questions click here. When they are clicked on they are routed to the forum annoucement. Problem is now that have deleted phpBB2 people are clicking on the forum annoucement URL and its basically a dead URL.

I tried to play with the up above files and create profile.php file, but well I can't figure it out.
Own a Jeep? Links4Jeeps.com

Advertisement: