XF 1.3 URL Redirects not working phpBB to XF

clove28

Active member
I am having a problem in creating a url redirect after importing phpbb to xenforo. I tried the scripts available in the resource but none is working. I tried to search Google using the keyword I was ranking at to check but it only shows 404.:(
 
Here is the redirect code I got but I don't know where to put this line..

define('IMPORT_LOG_TABLE', 'import_log_old_forum');>

in this code..

Code:
<?php
/**
* phpBB redirection script for XenForo
*
* by Simon Tunnat
*/

function redirect($url) {
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: ' . $url);
    exit;
}

$type = null;
$page = null;
$id = null;

if ( isset($_SERVER['REQUEST_URI']) ) {
    $url = explode('/', $_SERVER['REQUEST_URI']);
    $url = explode('.', array_pop($url));

    if( $url[0] == 'viewforum' && isset($_GET['f']) ) {
        $type = 'forums';
        $id = intval($_GET['f']);
    } elseif( $url[0] == 'viewtopic' ) {
        if( isset($_GET['p']) ) {
        $type = 'posts';
        $id = intval($_GET['p']);
        } elseif( isset($_GET['t']) ) {
            $type = 'threads';
        $id = intval($_GET['t']);
        }
    } 

    if( isset($_GET['start']) ) {
        $postsPerPage = 10;
        $page = intval($_GET['start']) / $postsPerPage;
    }
}

if( $type !== null && $id !== null && $id !== 0 ) {
    if( $page !== null ) {
        redirect('index.php?' . $type  . '/' . $id . '/page-' . $page);
    } else {
        redirect('index.php?' . $type  . '/' . $id . '/');
    }
} else {
    redirect('index.php');
}
 
If you are using a resource, you would need to post any questions in that resource's thread.

If you have maintained IDs, you can redirect directly via .htaccess. See these as examples:

https://xenforo.com/community/threads/redirecting-from-phpbb.75128/
https://xenforo.com/community/threads/phpbb-xf-htaccess.49011/

Hi Mike! Thanks for your reply.

I put this code to my htaccess.txt file

Code:
#<IfModule mod_security.c>
#    SecFilterEngine Off
#    SecFilterScanPOST Off
#</IfModule>
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.([^.]+)$
    RewriteRule ^(.*)$ http://%1.%2/$1 [R=301,L]
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{QUERY_STRING} (^|&)t=([0-9]+)(&|$) [NC]
    RewriteRule ^viewtopic\.php$ /threads/%2? [L,R=301,NC]
    RewriteCond %{QUERY_STRING} (^|&)p=([0-9]+)(&|$) [NC]
    RewriteRule ^viewtopic\.php$ /posts/%2? [L,R=301,NC]
    RewriteCond %{QUERY_STRING} f=(\d+)$ [NC]
    RewriteRule ^viewforum\.php$ /forums/%1 [L,R=301,NC]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>

Do I still need to put this code?

Code:
define('IMPORT_LOG_TABLE', 'import_log_old_forum');>

And once I put those code will there be an immediate effect or I need to wait for hours or day to see it? I'm really new to all these redirection so I couldn't understand very well. Thanks!:)
 
Top Bottom