A while ago i was asking how to redirect old URL from PHP-Fusion to new SMF2 (http://www.simplemachines.org/community/index.php?topic=417903.0) 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
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)
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 ;)
Maybe someone else have some ideas?
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]
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
Which one did you use?
The last I posted?
yes
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 = intval( substr( $_REQUEST['topic'], $_pid+4 ) );
$_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'].'&view=findpost&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);
}
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.
If you want to move it go ahead ;)
Still in URL is visible patch from FTP (/home/user/domain.xx/....) :/
Sorry for the double move...
Yep, I realized it's not working (yet)...maybe someone else has an idea on how to fix it...
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 ?).
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.
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?".
.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/
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.
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 :)
Great! :D
Okay, I'll add a reference to the first post of the converter.
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?
In your .htaccess file, probably before any SEO rewrites. If you're on an IIS (Windows) server, it would be implemented some other way (it doesn't use .htaccess).