Redirect IPB 3 URLs to SMF2 URLs ?

Started by Adrek, July 02, 2012, 09:25:45 AM

Previous topic - Next topic

Adrek

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:
http://example.pl/index.php?/topic/631-wymiana-linkami/
New URL:
http://example.pl/index.php?topic=631
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

Antes

#1
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)

Adrek

doesn't work for me:
QuoteInternal 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

the simplest solution is most likely the right one

Adrek

Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

emanuele

#4
Quote from: Antes on July 04, 2012, 05:24:29 AM
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:
RewriteCond %{QUERY_STRING} ^/topic/(.*)
RewriteRule ^(.+) index.php?topic=$1 [R=301,L]


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.

Adrek

Now this
http://example.pl/index.php?/topic/114-firefox-pl/page__st__20__gopid__9971#entry9971

is redirected to
http://example.pl/home/***/domains/***.pl/public_html/index.php?topic=index.php#entry9971

Quote from: emanuele on July 06, 2012, 11:45:35 AM
BTW I hate htaccess and it hates me... lol
the same here :E
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

emanuele

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.

Adrek

Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

Adrek

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 :)

<?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

the simplest solution is most likely the right one

emanuele

mmm...that should be a bt closer, but not sure what is wrong at the moment.
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.

Adrek

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

the simplest solution is most likely the right one

emanuele

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

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?

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 ?).

Adrek

#13
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:
http://example.pl/index.php?/topic/631-wymiana-linkami/
to
http://example.pl/index.php?topic=631

//edit
and this htaccess from post above doesn't work, it is only thing in file.
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

MrPhil

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?".

Adrek

.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
http://example.pl/index.php?/topic/631-wymiana-linkami/
it takes me to
http://example.pl/index.php?/topic/631-wymiana-linkami/
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

MrPhil

OK, try this:
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.

Adrek

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

the simplest solution is most likely the right one

emanuele

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.

Ventic

Quote from: MrPhil on July 13, 2012, 10:24:59 PM
OK, try this:
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?

Advertisement: