vBulletin 4.x URL Redirection

vBulletin 4.x URL Redirection 1.0.0

No permission to download
@slinouille

1) For that first type of URL you will need a rewrite rule. Add these rules to the top of the .htaccess file in your web root:

Code:
RewriteEngine On

RewriteRule ^showthread\.php/([0-9]+)-.*$ /showthread.php?t=$1 [R=301,L]

That should work.

2) It definitely sounds like you are using the wrong import log. Look in your database for other import log tables. The name is usually one of these two:

xf_import_log
archived_import_log


Then specify the name of that table in the 301config.php file.
 
Thanks for the rewrite rule ;)

Now concerning the import log, I do have the 2 tables xf_import_log and archived_import_log but the 1st one is empty and the 2d one is populated but with wrong data.
So you think, there is no way to get back the correct ids?
 
Thanks for the rewrite rule ;)

Now concerning the import log, I do have the 2 tables xf_import_log and archived_import_log but the 1st one is empty and the 2d one is populated but with wrong data.
So you think, there is no way to get back the correct ids?

When you imported did you maintain content ID's?

If the answer is yes, then you can use this:

Code:
INSERT INTO archived_import_log (content_type, old_id, new_id) SELECT 'user', user_id, user_id FROM xf_user ON DUPLICATE KEY UPDATE old_id = VALUES(old_id);
INSERT INTO archived_import_log (content_type, old_id, new_id) SELECT 'userGroup', user_group_id, user_group_id FROM xf_user_group ON DUPLICATE KEY UPDATE    old_id = VALUES(old_id);
INSERT INTO archived_import_log (content_type, old_id, new_id) SELECT 'post', post_id, post_id FROM xf_post ON DUPLICATE KEY UPDATE old_id = VALUES(old_id);
INSERT INTO archived_import_log (content_type, old_id, new_id) SELECT 'thread', thread_id, thread_id FROM xf_thread ON DUPLICATE KEY UPDATE old_id = VALUES(old_id);
INSERT INTO archived_import_log (content_type, old_id, new_id) SELECT 'poll', poll_id, poll_id FROM xf_poll ON DUPLICATE KEY UPDATE old_id = VALUES(old_id);
INSERT INTO archived_import_log (content_type, old_id, new_id) SELECT 'node', node_id, node_id FROM xf_node ON DUPLICATE KEY UPDATE old_id = VALUES(old_id);
INSERT INTO archived_import_log (content_type, old_id, new_id) SELECT 'attachment', attachment_id, attachment_id FROM xf_attachment ON DUPLICATE KEY UPDATE old_id = VALUES(old_id);
INSERT INTO archived_import_log (content_type, old_id, new_id) SELECT 'conversation', conversation_id, conversation_id FROM xf_conversation_master ON DUPLICATE KEY UPDATE old_id = VALUES(old_id);

If not, then no.
 
Thank you for the queries.

I've used them in order to populate the table with my own IDs (indeed it seems I didn't enabled "keep same ID" during importation).

In table xf_import_log (which is empty), I've added entries as this:
  • content type : 746872656164 (value for threads)
  • old_id : 32058 (using phpmyadmin fonction HEX)
  • new_id : 31201 (using phpmyadmin fonction HEX)
The redirection is now correct.

One more question: how do you explain that redirection works on Chrome but not on Firefox? Any idea?
 
One more question: how do you explain that redirection works on Chrome but not on Firefox? Any idea?

Firefox is probably caching the previous behavior. Relaunch the browser to test in FF.

Chrome doesn't usually have this problem, but it depends how the browser is configured.
 
This isnt working.

I had vbulletin fully rewrite the URLs, and I have the new forum also fully rewrite.
I installed this plugin and followed the instructions but it doesnt work.

the old link is redirecting to /post

I have nothing in htaccess for url rewrite
 
@Jake Bunce
I used this https://xenforo.com/community/threads/vbulletin-4-x-url-redirection.26935/page-11#post-963851
without the plugin and it works fine-ish right now.

but, it cannot redirect to posts. It redirects always to the first post.

Example
Old link:
http://www.playersdungeon.com/threads/30-GAME-Wordplay-)?p=2418&viewfull=1#post2418

New link:
http://www.playersdungeon.com/threads/game-wordplay.30/page-39#post-2418

But it redirects right now to:
http://www.playersdungeon.com/threads/game-wordplay.30/#post2418

I used mod_rewrite on vb, and I have mod-rewrite on xenforo settings enabled
 
@iraqiboy90

To handle that specific kind of URL, add these rules to the top of the .htaccess file in the web root (XF's .htaccess file):

Code:
RewriteEngine On

# make exception for XF's thread urls to avoid conflicts
RewriteRule ^threads/[^\./]+\.[0-9]+/ - [S=1]
# then redirect the old vB post urls
RewriteCond %{QUERY_STRING} (^|\?)p=([0-9]+)($|&)
RewriteRule ^threads/.+$ /posts/%2/? [R=301,L]

That should do it.
 
@iraqiboy90

To handle that specific kind of URL, add these rules to the top of the .htaccess file in the web root (XF's .htaccess file):

Code:
RewriteEngine On

# make exception for XF's thread urls to avoid conflicts
RewriteRule ^threads/[^\./]+\.[0-9]+/ - [S=1]
# then redirect the old vB post urls
RewriteCond %{QUERY_STRING} (^|\?)p=([0-9]+)($|&)
RewriteRule ^threads/.+$ /posts/%2/? [R=301,L]

That should do it.

Awesome man :)
Thank you very much :)

There are surely many with the same issue type, maybe Luke F can add this one to the top?
 

That should be handled by this addon. Otherwise here is an updated version of the previous rules to include that type of URL as well:

Code:
RewriteEngine On

# make exception for XF's thread urls to avoid conflicts
RewriteRule ^threads/[^\./]+\.[0-9]+/ - [S=2]
# then redirect the old vB post urls
RewriteCond %{QUERY_STRING} (^|\?)p=([0-9]+)($|&)
RewriteRule ^threads/.+$ /posts/%2/? [R=301,L]
RewriteRule ^threads/([0-9]+)-.*$ /threads/$1/ [R=301,L]
 
I'm hopeful someone can kindly assist me with a problem I have.

This mod made my transition from vb4 to Xenforo very easy, however last week Google sent me an alert of a sudden surge of 404s;

Screen_Shot_2016_02_23_at_20_18_59.png


"Googlebot couldn't crawl this URL because it points to a non-existent page."

The URLs Google are picking up are like so;


When it is actually;



Can anyone advise how I can resolve this so Google are picking up the correct URLs?
 
Last edited:
@DannyEFC

Add these rules to the top of the .htaccess file in the /forum directory (XF's .htaccess file):

Code:
RewriteEngine On

# make exception for XF's thread urls to avoid conflicts
RewriteRule ^threads/[^\./]+\.[0-9]+/ - [S=2]
# then redirect the old vB post urls
RewriteCond %{QUERY_STRING} (^|\?)p=([0-9]+)($|&)
RewriteRule ^threads/.+$ /forum/posts/%2/? [R=301,L]
RewriteRule ^threads/([0-9]+)-.*$ /forum/threads/$1/ [R=301,L]

This should work for thread redirects without any PHP redirect scripts since the ids are the same.
 
@DannyEFC

Add these rules to the top of the .htaccess file in the /forum directory (XF's .htaccess file):

Code:
RewriteEngine On

# make exception for XF's thread urls to avoid conflicts
RewriteRule ^threads/[^\./]+\.[0-9]+/ - [S=2]
# then redirect the old vB post urls
RewriteCond %{QUERY_STRING} (^|\?)p=([0-9]+)($|&)
RewriteRule ^threads/.+$ /forum/posts/%2/? [R=301,L]
RewriteRule ^threads/([0-9]+)-.*$ /forum/threads/$1/ [R=301,L]

This should work for thread redirects without any PHP redirect scripts since the ids are the same.

Thank you very much @Jake Bunce , appreciate it.

So this is my .htaccess;

htaccessscreen.jpg


But this is still happening;

googleerror.jpg


Doesn't exist:
Exists:

Any ideas?
 
Last edited:
I'm currently looking at redirecting old vB4 CMS articles also and haven't found a solution yet. Using the vB4 CMS to threads importer I do see in the archived_import_log article id mapped to post id. It will take another lookup for post id to thread id. I'll see if I can figure it out but if anyone has any suggested approaches they are welcome! :)

Figured it out i think. The files of the Redirection Script Addon were uploaded to the wrong folder.

Another question: many of my vB4 CMS Articles are linked from other forums/pages. Is there a way to redirect these links to the existing forum threads?

Old vB4 CMS Article Url structure:
www.domain.com/forum/content.php?305-Von

New xF Thread Url:
www.domain.com/forum/thema/von.1768/
 
Hi Jake or somebody else,

maybe you can help me also.
Since a few days I´am trying with a test migration to figure out the right redirection, but unfortunately without any success.
I tried a lot. For example, the script (vBulletin 4.x URL Redirection), the associated files, both together, a few of your posted .htaccess rules and the customized 301config.php.
Nothing works for me. The initial situation is: vBulletin 4.2.x with mod_rewrite modification.

Because my board is german, I customize the file " /includes/class_friendley_url.php"
with:
Code:
[/COLOR][/FONT][/SIZE][/SIZE][/COLOR][/FONT][/SIZE][/SIZE]
[SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)][SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)]    /**
    * The name of the script that the URL links to.
    *
    * @var string
    */
    protected $script = 'showthread.php';
    protected $script_base_option_name = 'vbforum_url';

    /**
    * The segment of the uri that identifies this type.
    *
    * @var string
    */
    protected $rewrite_segment = 'thema';
}
Replaced "threads" with "thema"


and
Code:
    /**[/COLOR][/FONT][/SIZE][/SIZE][/COLOR][/FONT][/SIZE][/SIZE]
[SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)][SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)]     * The name of the script that the URL links to.
     *
     * @var string
     */
    protected $script = 'forumdisplay.php';
    protected $script_base_option_name = 'vbforum_url';

    /**
     * The segment of the uri that identifies this type.
     *
     * @var string
     */
    protected $rewrite_segment = 'forum';
}
Replaced "forums" with "forum"


and
Code:
    /**[/COLOR][/FONT][/SIZE][/SIZE][/COLOR][/FONT][/SIZE][/SIZE]
[SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)][SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)]     * The name of the script that the URL links to.
     *
     * @var string
     */
    protected $script = 'member.php';
    protected $script_base_option_name = 'vbforum_url';

    /**
     * The segment of the uri that identifies this type.
     *
     * @var string
     */
    protected $rewrite_segment = 'mitglied';
}
Replaced "members" with "member"



accordingly I´ve modifyed the .htaccess
Code:
# Forum[/COLOR][/FONT][/SIZE][/SIZE][/COLOR][/FONT][/SIZE][/SIZE]
[SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)][SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)]RewriteRule ^thema/.* showthread.php [QSA]
RewriteRule ^forum/.* forumdisplay.php [QSA]
RewriteRule ^mitglied/.* member.php [QSA]
........

RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) [NC]
RewriteRule ^(.*) http://www.%1/$1 [R=301,NE,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

# MVC
RewriteRule ^(?:(.*?)(?:/|$))(.*|$)$ $1.php?r=$2 [QSA]

Reason and result was to have urls like:
Code:
http://www.myboard.com/forum/94-Neu-im-Kubaforum[/COLOR][/FONT][/SIZE][/SIZE][/COLOR][/FONT][/SIZE][/SIZE]
[SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)][SIZE=4][SIZE=14px][FONT=PT Sans Caption][COLOR=rgb(66, 66, 66)]http://www.myboard.com/thema/9884-Ich-bin-neu-im-Kubaforum
http://www.myboard.com/mitglied/2706-Susa

Although during the installation I have retained the IDs, all described redirection attempts has failed.
Maybe you know a solution for me?
 
Top Bottom