XF 1.2 Merged 2 xenforo sites

AWS

Well-known member
I recently acquired a forum in the same niche. I decided to merge the 2 rather than having 2 sites covering the same topic.

Is there a way to set redirect URLs of the merged site so that the links to the threads and posts are not broken?
 
Oh...

The page redirect needs to go before the non-page redirect.
Already gave that a shot. I have changed it to this now and same result:

Code:
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?aspergic\.com$
RewriteRule ^threads/[^\./]+\.([0-9]+)/page-([0-9]+) https://www.aspiescentral.com/showthread_aspergic.php?t=$1&page=$2 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?aspergic\.com$
RewriteRule ^threads/[^\./]+\.([0-9]+)/ https://www.aspiescentral.com/showthread_aspergic.php?t=$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?aspergic\.com$
RewriteRule ^members/[^\./]+\.([0-9]+)/ https://www.aspiescentral.com/member_aspergic.php?u=$1 [R=301,L]
 
301config_aspergic.php:

PHP:
<?php

/* ----------------------------------------------------------- *\
This variable defines where XenForo is installed.

If you have not installed XenForo into the same directory in which
vBulletin was installed, you will need to provide the full path to
the XenForo directory here. Remove the leading // and then enter
the path as in the following examples:
#
#    $fileDir = '/home/example/public_html/new_forums';
#
#    $fileDir = 'C:/inetpub/wwwroot/xenforo';
#
\* ----------------------------------------------------------- */

$fileDir = '/home/nginx/domains/aspiescentral.com/public';

/* ----------------------------------------------------------- *\
This constant defines the table from which the import redirection
scripts will fetch their data. Normally they will use the table
'xf_import_log', but if you have archived your import data, you
should provide the name of the archive table here. Remove the
leading // and then replace 'import_log_x' with the name of your
archive table, as in the following examples:
#
#    define('IMPORT_LOG_TABLE', 'my_import_log');
#
#    define('IMPORT_LOG_TABLE', 'import_log_my_forums');
#
\* ----------------------------------------------------------- */

define('IMPORT_LOG_TABLE', 'aspergic_import_log');

/* ----------------------------------------------------------- *\
This constant controls whether or not to include page number links
in your redirects. In order for this to work, the number of posts
shown per page in vBulletin MUST match the number of posts shown per
page in XenForo, and the number of threads shown per page on
vBulletin's thread listing pages must be the same as that used by
XenForo, or the links will be wrong. If they do not match, leave
this constant defined as 'false'. If they do match, change the
definition to 'true'.
\* ----------------------------------------------------------- */

define('INCLUDE_PAGE_LINKS', true);

showthread_aspergic.php:

PHP:
<?php

$startTime = microtime(true);

$fileDir = dirname(__FILE__);
if (file_exists($fileDir . '/301config_aspergic.php'))
{
    include($fileDir . '/301config_aspergic.php');
}

require($fileDir . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library');

XenForo_Application::initialize($fileDir . '/library', $fileDir);
XenForo_Application::set('page_start_time', $startTime);

$inputHandler = new XenForo_Input(new Zend_Controller_Request_Http());

$input = $inputHandler->filter(array(
    't' => XenForo_Input::UINT,
    'p' => XenForo_Input::UINT,
    'page' => XenForo_Input::UINT,
));

$importModel = XenForo_Model::create('XenForo_Model_Import');

$target = false;
if ($input['t'])
{
    if ($newId = $importModel->mapThreadId($input['t']))
    {
        $data = array('thread_id' => $newId);
        $extraParams = array();

        if (defined('INCLUDE_PAGE_LINKS') && INCLUDE_PAGE_LINKS && $input['page'])
        {
            $extraParams['page'] = $input['page'];
        }

        $target = XenForo_Link::buildPublicLink('canonical:threads', $data, $extraParams);
    }
}
else if ($input['p'])
{
    $newId = $importModel->mapPostId($input['p']);
    if ($newId)
    {
        $target = XenForo_Link::buildPublicLink('canonical:posts', array('post_id' => $newId));
    }
}

if (!$target)
{
    $target = XenForo_Link::buildPublicLink('canonical:index');
}

$response = new Zend_Controller_Response_Http();
$response->setRedirect(XenForo_Link::convertUriToAbsoluteUri($target), 301);
$response->sendResponse();
 
I followed these steps and finally I got my two forums succesfully merged.
But there's one extra step to be made: replace all mentions from old_url to new_url.

I tried this mysql queries (old forum = cuantificadores.com; new forum = swmania.com ):
Code:
UPDATE xf_conversation_message SET message = REPLACE(message, 'cuantificadores.com', 'swmania.com') WHERE message LIKE '%cuantificadores.com%';
UPDATE xf_post SET message = REPLACE(message, 'cuantificadores.com', 'swmania.com') WHERE message LIKE '%cuantificadores.com%';

Do I need to make anything else? I don't know much about mysql... ;)
 
That should replace message content.

You may though want to implement redirects so any traffic hitting the other URL is automatically redirected.
 
That should replace message content.

You may though want to implement redirects so any traffic hitting the other URL is automatically redirected.
Sure, the vBulletin redirect script is also implemented, works without problem with my Xenforo to Xenforo migration.

Thanks!
 
Top Bottom