vBulletin 4.x URL Redirection

vBulletin 4.x URL Redirection 1.0.0

No permission to download
@Royals

The ids are the same so you don't need these scripts. Just place these rules at the top of the .htaccess in web root:

Code:
RewriteEngine On

RewriteRule ^forums/forum\.php$ /forums/ [R=301,L]

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

RewriteRule ^forums/member\.php/([0-9]+)-.*$ /members/$1/ [R=301,L]

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

I'm importing with same Content IDs, regular vB4 (not vBSEO), "basic" URL, same number of messages per page (10) - but these rules aren't working.

First, I need to use ? instead of /, because I have basic URLs. But when I use question marks:

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

It does not match.

My other concern is around showthread.php - how can I include page numbers and post #?

Here is what I'm trying to make happen:

First Page
vBulletin:
https://www.mysite.com/showthread.php?32279-Sharing-gardening
xenForo:
https://www.mysite.com/threads/sharing-gardening.32279/

Second Page
vBulletin:
https://www.mysite.com/showthread.php?32279-Sharing-gardening/page2
xenForo:
https://www.mysite.com/threads/sharing-gardening.32279/page-2

Specific post on first page
vBulletin:
https://www.mysite.com/showthread.php?32279-Sharing-gardening&p=444958&viewfull=1#post444958
xenForo:
https://www.mysite.com/threads/sharing-gardening.32279/#post-444958

Specific post on second page
vBulletin:
https://www.mysite.com/showthread.php?32279-Sharing-gardening&p=444958&viewfull=1#444958
xenForo:
https://www.mysite.com/threads/sharing-gardening.32279/page-2#post-444958
 
Last edited:
Hi @Jake,

thank you for the fast answer. The examples are:

HTML:
Forum:
old: http://www.kubaforum.eu/thema/9901-Moin-Moin
new: http://dev.kubaforum.eu/threads/moin-moin.9901/

Thread:
old: http://www.kubaforum.eu/thema/9587-Ich-bin-ganz-aufgeregt
new: http://www.kubaforum.eu/thema/9587-Ich-bin-ganz-aufgeregt

Post:
http://www.kubaforum.eu/thema/9688-Vorstellung-)?p=27061&viewfull=1#post27061
http://dev.kubaforum.eu/threads/vorstellung.9688/#post-27061

Member:
old: http://www.kubaforum.eu/mitglied/2706-Susa
new: http://dev.kubaforum.eu/members/susa.2706/

Place these rules at the top of the .htaccess file in the web root of www.kubaforum.eu :

Code:
RewriteEngine On

RewriteCond %{QUERY_STRING} (^|\?)p=([0-9]+)($|&)
RewriteRule ^thema/([0-9]+)-.*$ http://dev.kubaforum.eu/posts/%2/? [R=301,L]
RewriteRule ^thema/([0-9]+)-.*$ http://dev.kubaforum.eu/threads/$1/? [R=301,L]
RewriteRule ^mitglied/([0-9]+)-.*$ http://dev.kubaforum.eu/members/$1/? [R=301,L]

That will handle threads, posts, and members.
 
I'm importing with same Content IDs, regular vB4 (not vBSEO), "basic" URL, same number of messages per page (10) - but these rules aren't working.

First, I need to use ? instead of /, because I have basic URLs. But when I use question marks:

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

It does not match.

My other concern is around showthread.php - how can I include page numbers and post #?

Here is what I'm trying to make happen:

First Page
vBulletin:
https://www.mysite.com/showthread.php?32279-Sharing-gardening
xenForo:
https://www.mysite.com/threads/sharing-gardening.32279/

Second Page
vBulletin:
https://www.mysite.com/showthread.php?32279-Sharing-gardening/page2
xenForo:
https://www.mysite.com/threads/sharing-gardening.32279/page-2

Specific post on first page
vBulletin:
https://www.mysite.com/showthread.php?32279-Sharing-gardening&p=444958&viewfull=1#post444958
xenForo:
https://www.mysite.com/threads/sharing-gardening.32279/#post-444958

Specific post on second page
vBulletin:
https://www.mysite.com/showthread.php?32279-Sharing-gardening&p=444958&viewfull=1#444958
xenForo:
https://www.mysite.com/threads/sharing-gardening.32279/page-2#post-444958

Query string (after ?) checking is a little different.

Add these rules to the top of the .htaccess file in your web root:

Code:
RewriteEngine On

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

That will take care of threads, paginated threads, and posts.
 
Hi @Jake Bunce
First I´ have to thank you very much.
The time which you dedicated to me and all the other users here. Incredible!
The rules which are postet from you are working perfectley!

Best regards
Dominik
 
Last edited:
Query string (after ?) checking is a little different.

Add these rules to the top of the .htaccess file in your web root:

Code:
RewriteEngine On

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

That will take care of threads, paginated threads, and posts.

Thank you SO much!!! Saved me hours and hours of work. Here are my full htaccess rules (based off of Jake's rules) for anyone searching the same thing. The scripts worked pretty well too, but I prefer the control of htaccess and not needing to use the database. We use basic vb4 URLs (showthread.php?38-thread-lala).

Only thing it doesn't do is attachment thumbnails (would need the function getAttachmentThumbnailUrl, which means you need PHP scripts), but it'll send the thumbnail to the full size, so I don't think the end of the world.

Code:
# Home
RewriteRule ^forum\.php$ /xf/? [R=301,L]

# Forums + Pagination
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)-[^/]+/page([0-9]+)$
RewriteRule ^forumdisplay\.php$ /xf/forums/%2/page-%3? [R=301,L]
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)-.*$
RewriteRule ^forumdisplay\.php$ /xf/forums/%2/? [R=301,L]

# Threads + Pagination
RewriteCond %{QUERY_STRING} (^|\?|&)p=([0-9]+)($|&)
RewriteRule ^showthread\.php$ /xf/posts/%2/? [R=301,L]
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)-[^/]+/page([0-9]+)$
RewriteRule ^showthread\.php$ /xf/threads/%2/page-%3? [R=301,L]
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)-.*$
RewriteRule ^showthread\.php$ /xf/threads/%2/? [R=301,L]

# Member
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)-.*$
RewriteRule ^member\.php$ /xf/members/%2/? [R=301,L]

# Archive
RewriteRule ^archive/index\.php/t-([0-9]+)\.html$ /xf/threads/$1 [R=301,L]
RewriteRule ^archive/index\.php/f-([0-9]+)\.html$ /xf/forums/$1 [R=301,L]

# CMS -> RM (we made a custom importer)
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)-.*$
RewriteRule ^content\.php$ /xf/resources/%2/? [R=301,L]

# Print Thread
RewriteCond %{QUERY_STRING} t=([0-9]+)(&|$)
RewriteRule ^printthread\.php$ /xf/threads/%1? [R=301,L]

# Show Post
RewriteCond %{QUERY_STRING} p=([0-9]+)(&|$)
RewriteRule ^showpost\.php$ /xf/posts/%1? [R=301,L]

# Attachments
RewriteCond %{QUERY_STRING} attachmentid=([0-9]+)(&|$)
RewriteRule ^attachment\.php$ /xf/attachments/%1? [R=301,L]
 
I must be doing something wrong. I have done the conversion from vBulletin and followed the instructions but all old vBulletin urls do not redirect correctly.

Take this url for example: http://www.nirmoladda.com/showthrea...-been-submitted-by-Love4U&p=509184#post509184

That just redirects back to the main forum page. Please can one can help me?

Here is my .htaccess:

Code:
#    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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    #    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]
    RewriteRule ^/showthread.php /showthread.php;
        RewriteRule ^/forumdisplay.php /forumdisplay.php;
</IfModule>
 
Not working for me. Some url are not redirects. Please let me know that how to get working?

Working : http://www.nirmoladda.com/showthread.php?141644&p=772627#post772627

Not working: http://www.nirmoladda.com/showthrea...-been-submitted-by-Love4U&p=509184#post509184

Add these rules to the top of the .htaccess file in your web root:

Code:
RewriteEngine On

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

That will take care of threads, paginated threads, and posts.

(this assumes XF is also installed in the web root and that XF uses the same ids)
 
Yes, We Added these rules to the top of the .htaccess file in my web root but i am still are not working. Do we need any edit 301config.php or showthread.php files?

This type URL link working: /showthread.php?141644&p=772627#post772627
This type URL link not working: /showthread.php?144484-A-new-application-for-Support-Team-has-just-been-submitted-by-Love4U&p=509184#post509184

Also please can you let me that, how to working this type URL link: /forum7/thread619-466.html

PHP:
RewriteEngine On

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

#    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 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    #    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>
 
We are just trying to redirect our tags from vBulletin to the XenForo forum home page. Seems simple right? Its simply not working. We've tried 100 variations. None work.

This is the goal. Can you get it to work?

Make this URL: http://www.hairlosstalk.com/interact/tags.php?tag=psoriasis
Go to: https://www.hairlosstalk.com/interact/

We have tried the following and none work:

RewriteRule ^tags.php$ https://www.hairlosstalk.com/interact/ [L,R=301,NC]
RewriteRule ^tags\.php/(.*) /interact/ [L,R=301]
RewriteRule ^tags\.php/(.*)$ /interact/ [L,R=301]
RewriteRule ^tags\.php/$ /interact [L,R=301]

Note: We are also redirecting vbulletin HTTP to xenforo HTTPS during this migration. So that redirect is also in the file.
 
We are just trying to redirect our tags from vBulletin to the XenForo forum home page. Seems simple right? Its simply not working. We've tried 100 variations. None work.

This is the goal. Can you get it to work?

Make this URL: http://www.hairlosstalk.com/interact/tags.php?tag=psoriasis
Go to: https://www.hairlosstalk.com/interact/

We have tried the following and none work:

RewriteRule ^tags.php$ https://www.hairlosstalk.com/interact/ [L,R=301,NC]
RewriteRule ^tags\.php/(.*) /interact/ [L,R=301]
RewriteRule ^tags\.php/(.*)$ /interact/ [L,R=301]
RewriteRule ^tags\.php/$ /interact [L,R=301]

Note: We are also redirecting vbulletin HTTP to xenforo HTTPS during this migration. So that redirect is also in the file.

Code:
RewriteRule ^tags\.php$ /interact/? [R=301,L]
 
God, I read thru these 13 pages 3 times over, and I am still at a lost, there is no clear directions at all, and all the examples seem to be related to vbseo or same ids or same directory which is NOT my case.

I hope someone can help.

Points:

#1 - Was running Vbulletin 4 for long with full-friendly mod rewrite rules
#2 - Vbulletin was install in the directory /maxcon_forums outside of root
#3 - During import i saved the log into table called 'max_vb1607_04'
#4 - Path to the server root is /var/www/virtual/maxconsole.net/
#5 - Xenforo is now installed in root (no directory).
#6 - I am also using XenPorta as my front page.

OLD URL:

http://www.maxconsole.com/maxcon_forums/threads/294184-RUMOR-Streaming-of-Xbox-One-Games-to-Mobile

NEW URL:

http://www.maxconsole.com/threads/rumor-streaming-of-xbox-one-games-to-mobile.41312/

I only want one .htaccess in the root and the old /maxcon_forums (vbulletin) directory been deleted.

What is the right setup for my redirects, I have edited the 301config.php pointing to the new path for xenforo and to the right log table, along with the vb4 redirect files into the root, plus i installed the vb4 mod since the first attempts didn't work and my content ids are not the same.

And no matter what I try, I get either a white page, or 500 error, or everything going to the main front page, or a 404 error.

Please help.

Thanks!

-=(Gary)=-

P.S. -- I wish someone would write up a clear guide on different setups like FAQ and add it to the docs, the docs are so little and these 13 pages of questions and answers are a mess.
 
@/GriFFin

Add these rules to the top of the .htaccess file in your maxcon_forums directory:

Code:
RewriteEngine On

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

Then upload the PHP redirect scripts from this addon into your web root (where XF is). You might need to edit the 301config.php file to specify the import log table which is usually one of these:

xf_import_log
archived_import_log
 
Thanks @Jake Bunce

The redirect worked (almost), I ended up having to rewrite it a bit, since my old vbulletin was in a difference directory then xenforo is now which is in the root, so I ended up with the working code as follows:

Code:
# New Change (Vbulletin to XenForo)
RewriteCond %{THE_REQUEST} ^GET\ /maxcon_forums/
RewriteRule ^maxcon_forums/(.*) /forums/$1 [L,R=301]

# Convert All (Vbulletin URLs to XenForo system)
RewriteRule ^forums/threads/([0-9]+)- /showthread\.php?t=$1 [R=301,L]
RewriteRule ^forums/forums/([0-9]+)-(.*) /forumdisplay\.php?f=$1 [R=301,NC,L]

And i tested it and its working nice, all the my old threads, and added a line at the bottom, for redirecting the old forums also, now I just need to figure out the similar syntax for the full-friendly mod-rewrite url's for my old members, showpost, printthread, attachment ids.

Plus since I deleted the vbulletin and its directory (maxcon_forums) I need to figure out how to redirect these which are coming up now as 404 file not found:

http://www.maxconsole.com/maxcon_forums/index.php <--- should go to http://www.maxconsole.com/forums/
http://www.maxconsole.com/maxcon_forums/forum.php <-- should go to http://www.maxconsole.com/forums/
http://www.maxconsole.com/maxcon_forums/news.php <-- should go to http://www.maxconsole.com/

Any help with the remaining would be most welcome, at least now thanks to you the old threads and forums are getting correctly redirected!
 
@/GriFFin

I need example URLs from vB4 for members, showpost, printthread, and attachments. There are several possible formats that vB4 uses so I can't be sure without examples.

Here are rules for those 3 specific redirects:

Code:
RewriteRule ^index\.php$ /forums/? [R=301,L]
RewriteRule ^forum\.php$ /forums/? [R=301,L]
RewriteRule ^news\.php$ /? [R=301,L]
 
Thanks again @Jake Bunce for your help, after much testing of various links, I found I just could not get everything to work both full-friendly url's and old style vbulletin links using just one .htaccess and no original old directory, so my final setup is as follows, for everyone else having similar problems.

Point #1: Original Vbulletin was running full-friendly mod-rewrite urls at the time of converting over to xenforo
Point #2: Back in the past, we used to have standard urls so we need those to work also.
Point #3: Our Vbulletin was installed in /maxcon_forums but Xenforo is installed in root.
Point #4: Content IDs are NOT the same between vbulletin & xenforo and import log been archived into a table.

So working setup was as follows, installing this set of vb4 redirect mod files with 301config.php in BOTH root / and the now empty /maxcon_forums directory
Adding in to /maxcon_forums directory just the archive directory and its index.php file from the older vb3 mod redirect files.

Making up this new .htaccess in the /maxcon_forums directory:

Code:
# Convert All (Vbulletin URLs to XenForo system)
RewriteRule ^threads/([0-9]+)- /showthread\.php?t=$1 [R=301,L]
RewriteRule ^forums/([0-9]+)-(.*) /forumdisplay\.php?f=$1 [R=301,NC,L]
RewriteRule ^members/([0-9]+)- /member\.php?u=$1 [R=301,L]

Using the normal default xenforo .htaccess in the root directory.

Since the files forum.php / index.php / news.php no longer existed in the maxcon_forums directory, I could not get redirects to work, no matter what i tried 404 would take over first, so instead I made up dummy php files with the same names and put the redirect in the php code using the location command with true, 301

All my test url's now seem to work correctly both older ones and friendly ones for example:


I could not get them to all work until i put the vb4 mod redirect files BOTH in the root and also in the old maxcon_forums directory.

Originally I wanted to get away with deleting the old directory and using only one .htaccess but no matter what I tried something would not work, but this way seems to be the best so anyone else that is merging in vbulletin to xenforo and content ids have changed, and also the main forum directory, this setup should work as example.

Thanks everyone for their help, if I come across any more problems, or if anyone has more to add or things I can improve, please suggest them.

Take Care
 
Hello,
I did a move to Xenforo from vB 4 a few months ago, and got a few issues I'm still working out. I used this vB 4 redirection script, and it seemed to work mostly well.

However, I got this from a member recently:
So, if you have an old link like this:http://www.domain.com/forum/showthread.php?44259
Then going there will just bring you to the homepage, and you better hope you know the link and know how to turn it into the new format of http://www.domain.com/forum/threads/44259, or else you can't find the topic. If you have the name of the topic in the link too, it works, but the number used to be fine and now it isn't. OK, that's not so bad if you know what to do. But...

How about if you have an old "permalink" to a post? https://www.domain.com/forum/showthread.php?1788-Test-Thread&p=1126528#post1126528 This isn't some random link I came up with, but actually a link from the a page on the official wiki of the site. OK, now how do I find the post? If you look at the format of a post "permalink", and then paste that post number in there, you get nothing useful because the URL has to include the page number too! That is, it goes to the page number in the URL and then shows you the post if it's there. But how to get the page number? I honestly can't think of any way to get to that post, short of manually doing some kind of binary search through the pages of the thread to see where that post number might be.

Can I please get some assistance in making these sorts of old permalinks redirect properly to the correct posts?

Thanks!
 
@PJK

Add these rules to the top of the .htaccess file in the /forum directory:

Code:
RewriteEngine On

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

That should do it.
 
Top Bottom