Advertisement:

Author Topic: Redirect IPB 3 URLs to SMF2 URLs ?  (Read 14692 times)

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Redirect IPB 3 URLs to SMF2 URLs ?
« on: July 02, 2012, 09:25:45 AM »
A while ago i was asking how to redirect old URL from PHP-Fusion to new SMF2 format.

Now I have similar question :)

How to redirect URLs from IPB3 to SMF2?

Old URL:
Code: [Select]
http://example.pl/index.php?/topic/631-wymiana-linkami/New URL:
Code: [Select]
http://example.pl/index.php?topic=631
« Last Edit: July 02, 2012, 12:16:16 PM by phantomm »
Polskie wsparcie SMF na simplemachines.org

My mods

Offline Antes

  • Evil Black Cat
  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,648
  • Gender: Male
  • Black cat rulz!
    • Antes on GitHub
    • merta on LinkedIn
    • @antesistan on Twitter
    • Lunarfall
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #1 on: July 04, 2012, 05:24:29 AM »
Code: [Select]
RedirectMatch 301 /index.php?/topic/(.*) /index.php?topic=$1
your smf links became something like this (i think)

.../index.php?topic=631-wymiana-linkami (which needs to work too)
« Last Edit: July 06, 2012, 12:44:07 PM by Antes »
Active Project(s): [ SimpleDesk ] # [ Lunarfall ] # [ CoreStore ]

Past Project(s): [ ezPortal ]

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #2 on: July 04, 2012, 06:03:49 AM »
doesn't work for me:
Quote
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@*** and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2 Server at *** Port 80

but thanks for trying ;)
Polskie wsparcie SMF na simplemachines.org

My mods

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #3 on: July 06, 2012, 11:35:52 AM »
Maybe someone else have some ideas?
Polskie wsparcie SMF na simplemachines.org

My mods

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #4 on: July 06, 2012, 11:45:35 AM »
Code: [Select]
RedirectMatch 301 /index.php?/topic/(*.) /index.php?topic=$1
It should be .*, not *. I think.
BTW I hate htaccess and it hates me... lol

Looking around I think this should work:
Code: [Select]
RewriteCond %{QUERY_STRING} ^/topic/(.*)
RewriteRule ^(.+) index.php?topic=$1 [R=301,L]
« Last Edit: July 06, 2012, 12:06:09 PM by emanuele »


Take a peek at what I'm doing! ;D



Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #5 on: July 06, 2012, 12:35:41 PM »
Now this
Code: [Select]
http://example.pl/index.php?/topic/114-firefox-pl/page__st__20__gopid__9971#entry9971
is redirected to
Code: [Select]
http://example.pl/home/***/domains/***.pl/public_html/index.php?topic=index.php#entry9971
BTW I hate htaccess and it hates me... lol
the same here :E
Polskie wsparcie SMF na simplemachines.org

My mods

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #6 on: July 06, 2012, 01:04:42 PM »
Which one did you use?
The last I posted?


Take a peek at what I'm doing! ;D



Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #7 on: July 06, 2012, 01:20:56 PM »
yes
Polskie wsparcie SMF na simplemachines.org

My mods

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #8 on: July 08, 2012, 02:23:03 AM »
Here is small script that IPB Team gives to change links from SMF>IPB, maybe this will help with changing links from IPB to SMF :)
Code: [Select]
<?php
/**
 * IPS Converters
 * SMF Links
 * Last Update: $Date: 2011-11-18 18:13:29 +0000 (Fri, 18 Nov 2011) $
 * Last Updated By: $Author: AlexHobbs $
 *
 * @package IPS Converters
 * @author  Mark Wade
 * @copyright (c) 2009 Invision Power Services, Inc.
 * @link http://external.ipslink.com/ipboard30/landing/?p=converthelp
 * @version $Revision: 602 $
 */

//-----------------------------------------
// Configuration
//-----------------------------------------

// THE URL TO YOUR IPB FORUMS (no trailing slash or index.php)
define('IPB_URL''http://localhost/ipb3');

// THE PATH TO YOUR IPB FORUMS (no trailing slash)
define('IPB_PATH''/home/Users/Mark/Sites/ipb3');

// THE CONVERSION ID
// This would have been asked for when setting up the converters
define('CONV_ID''old_forums');

//-----------------------------------------
// Load our libraries
//-----------------------------------------

if (!file_exists(IPB_PATH.'/initdata.php'))
{
echo 'Invalid IPB path';
exit;
}

// Friendly URLs
$qs explode(','str_replace'/index.php/'''$_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'] : $_SERVER['REQUEST_URI'] ) );

if ( $qs[0] == 'topic' )
{
$_REQUEST['topic'] intval$qs[1] );
$_GET['topic'] $_REQUEST['topic'];
}

//-----------------------------------------
// Who am I and where are you!?
//-----------------------------------------

$ident    '';
$convType '';
$url      '';
$table   = '';
$urlPid   0;

if ($_REQUEST['board'])
{
$ident 'board';
$convType 'forums';
$url 'showforum';
}
elseif ($_REQUEST['topic'])
{
$ident 'topic';
$convType 'topics';
$url 'showtopic';
$table '_topics';

/* Search for PID */
$_pid strpos($_REQUEST['topic'], '.msg');

if ( $_pid !== FALSE )
{
$urlPid intvalsubstr$_REQUEST['topic'], $_pid+) );
$_REQUEST['topic'] = substr$_REQUEST['topic'], 0$_pid );

/* Reset $_GET as well */
$_GET['topic'] = $_REQUEST['topic'];
}
}
elseif (preg_match('/profile/'$_REQUEST['action']))
{
$ident 'u';
$convType 'members';
$url 'showuser';
}
else
{
define'IPB_THIS_SCRIPT''public' );
require_once( IPB_PATH.'/initdata.php' );

require_once( IPS_ROOT_PATH 'sources/base/ipsRegistry.php' );
require_once( IPS_ROOT_PATH 'sources/base/ipsController.php' );

ipsController::run();

exit();
}

require_once( IPB_PATH.'/initdata.php' );
require_once( IPB_PATH.'/'.CP_DIRECTORY.'/sources/base/ipsRegistry.php' );
require_once( IPB_PATH.'/'.CP_DIRECTORY.'/sources/base/ipsController.php' );
$registry ipsRegistry::instance();
$registry->init();
$DB       $registry->DB();

if ($ident == 'u')
{
$explode explode('='$_REQUEST['action']);
ipsRegistry::$request[$ident] = array_pop($explode);
}

//-----------------------------------------
// Do we have a valid ID number?
//-----------------------------------------

if (!is_numeric(ipsRegistry::$request[$ident]))
{
// Boink to index
$registry->getClass('output')->silentRedirect(IPB_URL''TRUE);
}

//-----------------------------------------
// Do we have a valid app?
//-----------------------------------------

$app $DB->buildAndFetch( array( 'select' => 'app_id''from' => 'conv_apps''where' => "name='".CONV_ID."'" ) );

if (!$app['app_id'])
{
echo 'Invalid Conversion ID';
exit;
}

//-----------------------------------------
// Get our link and boink
//-----------------------------------------

$row $DB->buildAndFetch( array( 'select' => 'ipb_id''from' => 'conv_link'.$table'where' => "foreign_id='".intval(ipsRegistry::$request[$ident])."' AND type='".$convType."' AND app='".$app['app_id']."'" ) );

if ( $row['ipb_id'] )
{
if ( $urlPid )
{
$pidData $DB->buildAndFetch( array( 'select' => 'ipb_id''from' => 'conv_link_posts''where' => "foreign_id=".$urlPid." AND type='posts' AND app='".$app['app_id']."'" ) );

if ( $pidData['ipb_id'] )
{
$registry->getClass('output')->silentRedirect(IPB_URL.'/index.php?'.$url.'='.$row['ipb_id'].'&amp;view=findpost&amp;p='.$pidData['ipb_id'], ''TRUE);
}
}

/* Fallback if no PID */
$registry->getClass('output')->silentRedirect(IPB_URL.'/index.php?'.$url.'='.$row['ipb_id'], ''TRUE);
}
else
{
// Failed to retrieve ID... Boink to index
$registry->getClass('output')->silentRedirect(IPB_URL''TRUE);
}
Polskie wsparcie SMF na simplemachines.org

My mods

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #9 on: July 09, 2012, 05:15:11 AM »
mmm...that should be a bt closer, but not sure what is wrong at the moment.
Code: [Select]
RewriteCond %{QUERY_STRING} ^/topic/(.*)
RewriteRule ^(.*)$ index.php?topic=%1 [R=301,L]

BTW I think this discussion would have higher visibility in another board like help wanted or scripting help.


Take a peek at what I'm doing! ;D



Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #10 on: July 11, 2012, 08:13:38 AM »
If you want to move it go ahead ;)

Still in URL is visible patch from FTP (/home/user/domain.xx/....) :/
Polskie wsparcie SMF na simplemachines.org

My mods

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #11 on: July 11, 2012, 08:34:18 AM »
Sorry for the double move...

Yep, I realized it's not working (yet)...maybe someone else has an idea on how to fix it...


Take a peek at what I'm doing! ;D



Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

MrPhil

  • Guest
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #12 on: July 11, 2012, 11:53:01 AM »
I'd be happy to take a look at it, but let's start at the beginning. What is the template for the incoming URL, and what do you want to turn it into? Is it still

http://example.pl/index.php?/topic/631-wymiana-linkami/

to

http://example.pl/index.php?topic=631.0

? Is there any SEO involved on the SMF side?

Code: [Select]
RewriteEngine On
# this has to come before all SMF-related processing
RewriteCond  %{REQUEST_URI}  ^/index\.php\?/topic/(\d+).*$  [NC]
RewriteRule  index\.php\?/topic/(\d+)  /index.php?topic=$1.0 [R=301,L]
might work, as long as it's at the top of /.htaccess, before SMF SEO processing. If it doesn't, it's possible that the Query String is being stripped off at the beginning (if anything after the ? isn't picked up) and/or is being glued back on at the end (get /topic/631-wymiana-linkami/ on the end). In either case, we'll have to try another approach, but first I want to make sure that first URL is correct (/ stuff after a ?).

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #13 on: July 11, 2012, 12:05:02 PM »
Now (10 minutes ago...) when owner of this site decided to use SimpleSEF, 'index.php?' is removed from all URLs.

would be best to rewrite:
Code: [Select]
http://example.pl/index.php?/topic/631-wymiana-linkami/to
Code: [Select]
http://example.pl/index.php?topic=631
//edit
and this htaccess from post above doesn't work, it is only thing in file.
« Last Edit: July 11, 2012, 01:03:17 PM by phantomm »
Polskie wsparcie SMF na simplemachines.org

My mods

MrPhil

  • Guest
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #14 on: July 12, 2012, 09:33:46 AM »
When you say "it doesn't work", what is happening? Is it gluing unwanted Query String information onto the end of the URL, or is there no change at all to the URL (pattern not recognized)? It actually says "/index.php?/" and not just "/index.php/"?

This is in the site root / .htaccess file, and not in some subdirectory? I don't know how many times I've beaten my head against the wall trying to diagnose problems, and finally the admin says "Oh, I put it in /forum/.htaccess. No difference, right?".

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #15 on: July 13, 2012, 09:14:54 AM »
.htacces is directly in public_html (this is root SMF directory).

"It doesn't work" meant that URL is not redirected at all. When I go to
Code: [Select]
http://example.pl/index.php?/topic/631-wymiana-linkami/it takes me to
Code: [Select]
http://example.pl/index.php?/topic/631-wymiana-linkami/
Polskie wsparcie SMF na simplemachines.org

My mods

MrPhil

  • Guest
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #16 on: July 13, 2012, 10:24:59 PM »
OK, try this:
Code: [Select]
RewriteEngine On
# this has to come before all SMF-related processing
RewriteCond  %{REQUEST_URI}  ^/index\.php  [NC]
RewriteCond  %{QUERY_STRING} ^/topic/(\d+).*$  [NC]
RewriteRule  ^.  /index.php?topic=%1.0 [R=301,L]

Apparently it's treating everything after the ? as a URL Query String, and stripping it off at the beginning. So, we handle the QUERY_STRING separately.

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,063
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #17 on: July 14, 2012, 03:15:30 AM »
It works! :D
Thank you very much for taking time to solve this!

@emanuele, would be good idea to link this topic in IPB converter topic, that others could use it as well :)
Polskie wsparcie SMF na simplemachines.org

My mods

Offline emanuele

  • SMF Super Hero
  • *******
  • Posts: 14,156
  • Gender: Male
  • THERE'S JUST ME
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #18 on: July 14, 2012, 01:08:54 PM »
Great! :D

Okay, I'll add a reference to the first post of the converter.


Take a peek at what I'm doing! ;D



Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Ventic

  • Full Member
  • ***
  • Posts: 635
  • Gender: Male
    • vasilis.koukoutis on Facebook
    • @joyspotorg on Twitter
    • JoySpot
Re: Redirect IPB 3 URLs to SMF2 URLs ?
« Reply #19 on: September 22, 2012, 02:46:03 PM »
OK, try this:
Code: [Select]
RewriteEngine On
# this has to come before all SMF-related processing
RewriteCond  %{REQUEST_URI}  ^/index\.php  [NC]
RewriteCond  %{QUERY_STRING} ^/topic/(\d+).*$  [NC]
RewriteRule  ^.  /index.php?topic=%1.0 [R=301,L]

Apparently it's treating everything after the ? as a URL Query String, and stripping it off at the beginning. So, we handle the QUERY_STRING separately.
and where i suppose to add this?