vBulletin 4.x URL Redirection

vBulletin 4.x URL Redirection 1.0.0

No permission to download

Remove (or rename) the old /forums directory.

Then add this to the top of the .htaccess file in the web root (which should be XF's .htaccess file):

Code:
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?)threadid=([0-9]+)($|&)
RewriteRule ^forums/showthread\.php$ /threads/%2/? [R=301,L]

RewriteRule ^[^/]+/([0-9]+)-.+-([0-9]+)\.html$ /threads/$1/page-$2 [R=301,L]

RewriteRule ^[^/]+/([0-9]+)-[^\.]+\.html$ /threads/$1/ [R=301,L]
 
Hi Jake,

Thank you for your work, but a rule does not work:

Code:
RewriteRule ^[^/]+/([0-9]+)-.+-([0-9]+)\.html$ /threads/$1/page-$2 [R=301,L]

It's not about on page 2 :(
 
Hi Jake,

Thank you for your work, but a rule does not work:

Code:
RewriteRule ^[^/]+/([0-9]+)-.+-([0-9]+)\.html$ /threads/$1/page-$2 [R=301,L]

It's not about on page 2 :(

The rule is correct from what I can see. Make sure XF has the same number of messages per page as vB:

Admin CP -> Options -> Messages -> Messages Per Page
 
After creating a test forum on a different subdomain than the live one (let's call it test.xf versus live.vb) and a successful import from vB to XF, despite doing all the steps described here and on the XF help page - http://xenforo.com/help/import-redirection/ - whenever we try to test a redirect, we always end up on the forum homepage.

So for instance http://test.xf/threads/123-thread (old style URL) goes to the homepage, even though it should redirect to http://test.xf/thread.123/ (a link which exists and can be accessed manually by browsing the new forum).

Things to note:

1. Vbulletin URL type: Mod Rewrite Friendly URLs
2. XenForo Use Full Friendly URLs - Yes
3. XenForo Include Content Title in URLs - Yes
4. Were the IDs retained in the vBulletin -> XenForo import? Yes
5. Archived import log specified in the 301config.php file? Yes
6. Have you tried installing the redirect add-on as well? Yes
7. The live vBulletin server is installed in the docroot? (no /forums, /forum, etc?) Yes
8. Is the XF test forum installed in a docroot as well? Yes

Any suggestions on how we might go about debugging this issue?
 
whenever we try to test a redirect, we always end up on the forum homepage.

That will happen if the import_log table is wrong.

Confirm the name of your import_log in the database. It is usually one of these:

xf_import_log
archived_import_log


Then edit the 301config.php file to specify the name of that table.
 
For us it's default_import_log, but it's correctly specified in the 301config.php file.

What I'm not 100% sure about is the htaccess rewrite rules. The vB one has the following rewrites:

# Forum
RewriteRule ^blogs/.* blog.php [QSA]
RewriteRule ^entries/.* entry.php [QSA]
RewriteRule ^threads/.* showthread.php [QSA]
RewriteRule ^forums/.* forumdisplay.php [QSA]
RewriteRule ^members/.* member.php [QSA]

Where should these exist in the XF htaccess file, if at all?
 
Showpost.php is not working for me, I believe because the page number for a given post is not generated. To explain:

Using URLs from this forum, this is the permalink for post 696399, note '/page-2/'

http://xenforo.com/community/threads/where-xenforo-falls-short.66246/page-2#post-696399

if I remove the page 2:

http://xenforo.com/community/threads/where-xenforo-falls-short.66246/#post-696399
or
http://xenforo.com/community/threads/where-xenforo-falls-short.66246#post-696399

the link will no longer work, but goes instead to the first post in the thread. so XF does seem to need the page number.

Can anyone confirm that or offer a cure? If not then I will try to modify showpost.php to get the page number
 
Actually quite straightforward, I believe the fix (if it isn't just me being mad, and there is actually a bug) is to change the if block at line 29 of showpost.php to:

PHP:
if ($input['p'])
{
        $importModel = XenForo_Model::create('XenForo_Model_Import');
        $post_model = XenForo_Model::create('XenForo_Model_Post');

        if ($newId = $importModel->mapPostId($input['p']))
        {
                $post = $post_model->getPostById($newId);
                $page = floor($post['position'] / XenForo_Application::get('options')->messagesPerPage) + 1;

                $target = XenForo_Link::buildPublicLink('canonical:posts', array('post_id' => $newId,'page' => $page));
        }
}
 
Unfortunately, we're still stuck as far as the rewrites go.

We did another import, after solving the attachment issue, and the simple copying of the standard-advanced files and 301config.php file didn't do anything. XF would just give a 404 error when trying to access an old format link.

We then installed the mod_rewrite addon, at which point all the old format links started to go to the forum homepage, even though their correspondence existed (http://test.xf/threads/123-thread ---> http://test.xf/thread.123/)

Any tips on how we might go about solving this? Worse case scenario, I think we'll have to do everything via htaccess, since the IDs have stayed the same.
 
Bossman, I get the impression you're trying to do everything in one go. What I would suggest is dealing firstly with standard non-SEF VBulletin URLs and non-SEF XF urls and get those working using the redirect scripts. Then set up the SEF URLs in XF, test them, and try the scripts again, and so on. Bit by bit.

Once you have non-SEF VB URLs redirecting to SEF XF URLs, you just need to reapply the VBulletin redirects that you've listed above (except blog I assume). That rewrites your SEF VB URLs in to normal VB showforum.php type URLs, which are the actual files from this mod sitting in your XF installation directory. After that XF will do a 301 redirect to its own SEF format URLs, following the settings you've described in your post above, but that last part is completely distinct from the rest and should be kept so.

Unfortunately I can't help you more directly as I'm moving from non-standard VBSEO URLs rather than plain VB and not using Apache. If its any consolation I'm also dealing with PHPBB2 URLS from pre-VBulletin using look up tables, so I'm probably having even less fun that you!

I hope that's some help.
 
One more thing, just in case.... sometimes you overlook the obvious so, if you're using .htaccess rather than your httpd.conf for these settings, ensure that you are allowing overrides (AllowOverride All in your httpd.conf), and of course that the rewrite engine is on. Probably trying to teach you to suck eggs, but no harm in checking!
 
I've moved my forum to Xenforo and I'm also having issues with redirects..

I must be doing something wrong, but I am a newbie when it comes to redirects. Could someone check my info here?

My 301 config looks like:
<?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/public_html/www.british-filipino.co.uk';

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

And my .htcaccess is:
# Mod_security can interfere with uploading of content such as attachments. If you
# cannot attach files, remove the "#" from the lines below.
#<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
RewriteRule ^/old-dir/showthread.php /new-dir/showthread.php
RewriteRule ^/old-dir/forumdisplay.php /new-dir/forumdisplay.php

# If you are having problems with the rewrite rules, remove the "#" from the
# line that begins "RewriteBase" below. You will also have to change the path
# of the rewrite to reflect the path to your XenForo installation.
#RewriteBase /xenforo

# This line may be needed to enable WebDAV editing with PHP as a CGI.
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

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>

Can anyone point out my error?

An example of an old vbulletin link would be: http://www.british-filipino.co.uk/showthread.php?5828-Azimo-money-transfer-are-they-any-good

Thanks
 
the /old-dir/, /new-dir/ look odd, given that your URL doesn't have a directory in the path. I haven't set these up with .htaccess, but those rules seem to be generic for this structure:

www.mydomain.com has .htaccess above in it

VB is in: www.mydomain.com/old-dir/...

XF is in: www.mydomain.com/new-dir/..

If you have replaced VB with XF (and this mod) in www.mydomain.com/ then they won't do anything for you at all. Comment them out.

What is the symptom you're getting and where are your old and new installations?
 
Thanks for the reply hqarrse. Mike in support sorted it out for me, my error was mainly in the setup of the forum itself and not the redirection plugin/scripts.
 
Well, since we kept the content IDs for everything when doing the import, and the redirection scripts didn't seem to want to play nice, we ended up writing our own .htaccess rewrite rules, which you'll find below.

Keep in mind these rules work for the way our vBulletin 4 forum is set up:

1. Installed in the doc_root of the domain (ex: http://forum.domain.com)
2. Content IDs are kept during the import (so the thread with id #1234 in vBulletin still has id #1234 in XenForo).
3. vBulletin Options -> Friendly URLs is set to Mod Rewrite Friendly URLs
4. vBulletin Options -> Friendly URLs -> Friendly URL Unicode is set to Convert to UTF-8
5. Optional: for the Calendar links to work we used this add-on

The full .htaccess file:

HTML:
#Enable rewrite engine
RewriteEngine On

#XenForo Error pages
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default

#Let the standard XenForo links pass through as usual (workaround for situations where the forum/thread/member name starts with a number)
RewriteRule ^forums/(.*)\.([0-9]+) /forums/$1\.$2 [NC]
RewriteRule ^threads/(.*)\.([0-9]+) /threads/$1\.$2 [NC]
RewriteRule ^members/(.*)\.([0-9]+) /members/$1\.$2 [NC]

#Then redirect vBulletin 4 SEF links. Specific rules need to be first in line, followed by the generic ones

#Redirect generic forum links
RewriteRule ^forums/([0-9]+)-(.*) /forums/$2\.$1 [R=301,NC,L]

#Redirect forum RSS links
RewriteCond %{QUERY_STRING} ^type=RSS2&forumids=(\d+)$
RewriteRule ^external\.php$ /forums/%1/index.rss? [R=301,NC,L]

#Redirect specific post thread links
RewriteCond %{QUERY_STRING} ^p=(\d+)&viewfull=(\d+)$
RewriteRule ^threads/([0-9]+)-(.*)$ /threads/$2\.$1/\#post-%1? [R=301,NC,NE,L]

#Redirect second type of specific post thread links
RewriteCond %{QUERY_STRING} ^p=(\d+)$
RewriteRule ^threads/([0-9]+)-(.*)$ /threads/$2\.$1/\#post-%1? [R=301,NC,NE,L]

#Redirect thread pages links
RewriteRule ^threads/([0-9]+)-(.*)/page(\d+) /threads/$2\.$1/page-$3 [R=301,NC,L]

#Redirect generic thread links
RewriteRule ^threads/([0-9]+)-(.*) /threads/$2\.$1 [R=301,NC,L]

#Redirect member links
RewriteRule ^members/([0-9]+)-(.*) /members/$2\.$1#info [R=301,NC,NE,L]

#Redirect registration link
RewriteRule ^register\.php /register [R=301,NC,L]

#Redirect memberlist link
RewriteRule ^memberlist\.php /members/list [R=301,NC,L]

#Redirect attachment links
RewriteCond %{QUERY_STRING} ^attachmentid=(\d+)&d=(\d+)$
RewriteRule ^attachment\.php$ /attachments/%1/? [R=301,NC,NE,L]

#Redirect archive forum links
RewriteRule ^archive/index.php/f-(\d+)\.html /forums/$1 [R=301,NC,L]

#Redirect archive thread links
RewriteRule ^archive/index.php/t-(\d+)\.html /threads/$1 [R=301,NC,L]

#Redirect archive index
RewriteRule ^archive/index.php / [R=301,NC,L]

#Redirect archive index
RewriteRule ^archive/ / [R=301,NC,L]

#Redirect FAQ index
RewriteRule ^faq\.php /help [R=301,NC,L]

#Redirect lost password links
RewriteCond %{QUERY_STRING} ^do=lostpw$
RewriteRule ^login\.php$ /lost-password/? [R=301,NC,L]

#Redirect Print thread links
RewriteCond %{QUERY_STRING} ^t=(\d+)&(.*)
RewriteRule ^printthread\.php$ /threads/%1/? [R=301,NC,L]

#Redirect calendar link
RewriteRule ^calendar.php /threads/calendar/ [R=301,NC,L]

#Redirect default forum link
RewriteRule ^forum.php / [R=301,NC,L]

#Redirect all groups links
RewriteCond %{QUERY_STRING} ^do=grouplist(.*)
RewriteRule ^group\.php$ /members/list? [R=301,NC,L]

#Redirect main group link
RewriteRule ^group.php /members/list [R=301,NC,L]

#XenForo default rules
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]
 
Last edited:
OK, well since you're not using this mod, and that's what I was trying to help with, then there's not much I can comment on! Good luck with the move
 
Well, the above rules can also be used as a baseline if someone imports the vBulletin content with different ids and does want to use the scripts, by pointing the various redirects to the relevant .php files.

For instance

Code:
#Redirect generic forum links
RewriteRule ^forums/([0-9]+)-(.*) /forums/$2\.$1 [R=301,NC,L]
can be turned to

Code:
#Redirect generic forum links
RewriteRule ^forums/([0-9]+)-(.*) /forumdisplay\.php?f=$1 [R=301,NC,L]

In which case, the link:

http://forum.domain.com/forums/1234-test

would become

http://forum.domain.com/forumdisplay.php?f=1234

at which point the php redirect file takes over.

At least that's the theory anyway :)
 
hi friends i am going to switch from vb4 to xenforo. working at Testing till now.
i have some confusion. my forum is urdu language. after URL Redirect therds url like

in vb

http://www.domain.com/forums/showthread.php/3489-آج-کا-میڈیا-اور-بچوں-کی-تربیت

redirect to xenfor

http://www.domain.com/forum/threads/آج-کا-میڈیا-اور-بچوں-کی-تربیت.3489/

work fine but wehn i want redirect without therd name with only therd number like

vb4 url
http://www.domain.com/forums/showthread.php/3489

redirect to xenfor as
http://www.domain.com/forum

plz help me.
thanks
 
Last edited:
Top Bottom