XF 1.1 phpbb import, url redirect

Nudaii

Well-known member
howdy i am just moving a forum from phpbb to xenforo

the old folder was /forum

its doing to be top level now aka domain.com/

what would i need to redirect old urls to new etc?
 
You're right, that does require the IDs to be the same. I didn't actually look into it before.

In terms of structuring the redirects, I wouldn't redirect all of domain.com -- I'd just setup the specific phpBB redirects there, then perhaps redirect what doesn't match; you don't have to worry about renaming stuff then. The alternative would be to redirect to a sub-directory and you wouldn't need to rename anything for that either.

What redirects have you tried? (Or what's the closest to working that you have?)
 
Here is my current setup:

301config_phpbb.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/v6mustang.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', 'archived_import_log_v6mfxen');

/* ----------------------------------------------------------- *\
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', false);

showthread_phpbb.php

PHP:
<?php

$startTime = microtime(true);

$fileDir = dirname(__FILE__);
if (file_exists($fileDir . '/301config_phpbb.php'))
{
    include($fileDir . '/301config_phpbb.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();

nginx redirects being used:

Code:
if ($args ~ "(^|&)t=([0-9]+)(&|$)"){
    set $rule_0 1$rule_0;
    set $bref_2 $2;
}
if ($rule_0 = "1"){
    rewrite ^/viewtopic.php$ /showthread_phpbb.php?t=$bref_2 permanent;
}

This url is an old url that would hopefully redirect but it isn't: http://www.v6mustangforums.com/viewtopic.php?f=28&t=16407

If you click on that link it does something weird and appends the string twice.
 
For reference, this is Jake's original .htaccess recommendation for the above configuration:

Code:
RewriteCond %{QUERY_STRING} (^|&)t=([0-9]+)(&|$)
RewriteRule ^viewtopic.php$ /showthread_phpbb.php?t=%2 [L,R=301,NC]
 
I'm seeing this as a possible rewrite:
Code:
location / {
  if ($query_string ~ "(^|&)t=([0-9]+)(&|$)"){
    rewrite ^/viewtopic.php$ /showthread_phpbb.php?t=%2 redirect;
  }
}
Does that help?
 
I'm seeing this as a possible rewrite:
Code:
location / {
  if ($query_string ~ "(^|&)t=([0-9]+)(&|$)"){
    rewrite ^/viewtopic.php$ /showthread_phpbb.php?t=%2 redirect;
  }
}
Does that help?

Same result....

new conf file

Code:
#301 redirect non-www to www
server {
    server_name  v6mustang.com;
    rewrite ^    http://www.v6mustang.com$request_uri? permanent;
}

server {
  server_name www.v6mustang.com;

# ngx_pagespeed & ngx_pagespeed handler
include /usr/local/nginx/conf/pagespeed.conf;
include /usr/local/nginx/conf/pagespeedhandler.conf;
include /usr/local/nginx/conf/pagespeedstatslog.conf;

  # limit_conn limit_per_ip 16;
  # ssi  on;

  access_log /home/nginx/domains/v6mustang.com/log/access.log combined buffer=32k;
  error_log /home/nginx/domains/v6mustang.com/log/error.log;

  root /home/nginx/domains/v6mustang.com/public;

  location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$uri&$args;
# block common exploits, sql injections etc
#include /usr/local/nginx/conf/block.conf;

  # Enables directory listings when index file not found
  #autoindex  on;

  # Shows file listing times as local time
  #autoindex_localtime on;

  # Enable for vBulletin usage WITHOUT vbSEO installed
  #try_files        / /index.php;

  if ($query_string ~ "(^|&)t=([0-9]+)(&|$)"){
    rewrite ^/viewtopic.php$ /showthread_phpbb.php?t=%2 redirect;
  }


  }

  location /internal_data/ {
        internal;
}
location /library/ {
      internal;
}

location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass    127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
}

location /vb/ {
    rewrite ^/vb/f[\d]+/.+-([\d]+)/index([\d]+).html /vb/showthread.php?t=$1&page=$2 last;
    rewrite ^/vb/f[\d]+/.+-([\d]+)/ /vb/showthread.php?t=$1 last;
    rewrite ^/vb/f([\d]+)/index([\d]+).html /vb/forumdisplay.php?f=$1&page=$2 last;
    rewrite ^/vb/f([\d]+)/ /vb/forumdisplay.php?f=$1 last;
}

  include /usr/local/nginx/conf/staticfiles.conf;
  include /usr/local/nginx/conf/php.conf;
  include /usr/local/nginx/conf/drop.conf;
  #include /usr/local/nginx/conf/errorpage.conf;
}
 
I'm going to take a stab in the dark here:
Code:
location ~ viewtopic\.php$ {
try_files /showthread_phpbb.php?t=$arg_t =404;
}
 
I suppose you could just create the necessary PHP file directly and then just manipulate $_GET as necessary and then require showthread_phpbb.php - skip the rewrites entirely...
 
I suppose you could just create the necessary PHP file directly and then just manipulate $_GET as necessary and then require showthread_phpbb.php - skip the rewrites entirely...

Ok, so maybe I misunderstood you. I simply renamed it to viewtopic.php and didn't change anything. Now the redirect works. Didn't realize it would be that simple. o_O
 
Top Bottom