vBulletin 4.x URL Redirection

vBulletin 4.x URL Redirection 1.0.0

No permission to download
I have a CLUSTERF*** of a conundrum.

I recently rescued a site that was on vb4 for a good while, but just recently made the mistake of upgrading to vb5. I just recently converted it using the IP.board route. Content IDs were supposed to be retained, but they were not, and i DO have the archived_import_log table intact.

There's URLs in Google that has indexes from BOTH versions which I need to handle:

vb4: /forums/showthread.php/XXXXX-YYYYY (X=thread id, Y=thread title)
vb5: /forums/forum/CATEGORY-NAME/THREAD-TITLE/XXXXX (X=thread id)

Now, Xenforo is in the webroot. Can someone point me in the right direction to do this with htaccess (not one of my strong suits)?
 
Thanks Jake - I attempted that structure, but still get a redirect to the homepage.

Slightly modified... add these rules to the top of the .htaccess file in your web root (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/.+$ /posts/%2/? [R=301,L]
RewriteRule ^threads/([0-9]+)-.*$ /threads/$1/ [R=301,L]

That should do it.
 
Newbie to XF alert! Hope Jake is around!

vb4 is in /forum, XF is in root.
With vb4 we were using advanced friendly rules.

I have uploaded the standard-basic-advanced package to where our vb forum is /forum. Edited the 301config.php file and when I test an old thread I get error: the requested page could not be found.

Members:
Old VB:
https://yorkiepartners.com/forum/member.php/6-YorkieKat
New XF:
https://yorkiepartners.com/index.php?members/yorkiekat.6/
Showthread
Old VB:
https://yorkiepartners.com/forum/showthread.php/17517-Need-Help-Please-!
New XF:
https://yorkiepartners.com/index.php?threads/need-help-please.17517/

Old Vb:
https://yorkiepartners.com/forum/forumdisplay.php/11-YP-News
New XF:
https://yorkiepartners.com/index.php?forums/yp-news.11/

Have full friendly urls set in SEO Search Engine Optimization to get rid of index.php.

Current .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
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    #    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>
 
Last edited:
Its been 7 days since I switched the site over from vb to XF, still looking for a solution to get the redirects working. Anyone?
 
So we went from vb to xf, then xf to xf (via import since the DB had crashed and had to be recovered). So the latest import is from xf.

We have a lot of links from the VB era that I'd like to redirect; previously I'd used redirect files (showthread.php etc.), but when I try to use them now, they all redirect to the index. Checking the PHP files, this seems to indicate that $target was not valid.

Old URL 1: /vb/showthread.php/?t=90211.html
New URL 1: /threads/90211

Old URL 2: /vb/showthread.php/?t=90211
New URL 2: /threads/90211

Old URL 3: /vb/showthread.php?t=200328&p=2019284#post2019284
New URL 3: /200328/#post-2019284

Using nginx, if that makes a difference... everything would be fine and dandy if the redirect php files worked, but rewrite rules would be nice too.
 
Newbie to XF alert! Hope Jake is around!

vb4 is in /forum, XF is in root.
With vb4 we were using advanced friendly rules.

I have uploaded the standard-basic-advanced package to where our vb forum is /forum. Edited the 301config.php file and when I test an old thread I get error: the requested page could not be found.

Members:
Old VB:
https://yorkiepartners.com/forum/member.php/6-YorkieKat
New XF:
https://yorkiepartners.com/index.php?members/yorkiekat.6/
Showthread
Old VB:
https://yorkiepartners.com/forum/showthread.php/17517-Need-Help-Please-!
New XF:
https://yorkiepartners.com/index.php?threads/need-help-please.17517/

Old Vb:
https://yorkiepartners.com/forum/forumdisplay.php/11-YP-News
New XF:
https://yorkiepartners.com/index.php?forums/yp-news.11/

Have full friendly urls set in SEO Search Engine Optimization to get rid of index.php.

Current .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
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    #    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>

Add these rules to the top of the .htaccess file in your web root (assuming /forum no longer exists):

Code:
RewriteEngine On

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

...or if /forum still exists then use these rules in the .htaccess file in the /forum directory:

Code:
RewriteEngine On

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

That will take care of thread URLs which are the important URLs which currently aren't working on your forum from what I can see.
 
Having issues with my redirects as well, full friendly enabled:

Old profile:
http://www.bladeforums.com/forums/member.php/105215-Spark

New:
http://www.bladeforums.com/members/spark.105215/

Old thread:
/forums/showthread.php/1485279-We-will-be-changing-forums-software-in-the-next-48-72-hours

New:
/threads/we-will-be-changing-forums-software-in-the-next-48-72-hours.1485279/

Forumdisplay:
Old: /forums/forumdisplay.php/844-Service-amp-Support

New
http://www.bladeforums.com/categories/service-support.844/

.htaccess
# 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 showthread\.php/([0-9]+)-.*$ /showthread.php?t=$1 [R=301,L]
RewriteRule forumdisplay\.php/([0-9]+)-(.*)$ /index.php?forums/$2.$1/ [R=301,L]
RewriteRule ^.*$ index.php [NC,L]

RewriteRule [^/]+/([\d]+)-.+-([\d]+).html /showthread.php?t=$1&page=$2 [R=301,NC,L]
RewriteRule [^/]+/([\d]+)-.+.html /showthread.php?t=$1 [NC,L]
RewriteRule f([\d]+)/index([\d]+).html /forumdisplay.php?f=$1&page=$2 [R=301,NC,L]
RewriteRule f([\d]+)/ /forumdisplay.php?f=$1 [NC,L]
#RewriteRule ^/forums/showthread.php /showthread.php
#RewriteRule ^/forums/forumdisplay.php /forumdisplay.php

# RewriteRule ^/forums/forum.php / [R=301,NC,L]

Redirect 301 /forums/forumdisplay.php/718-Knife-Reviews-amp-Testing http://www.bladeforums.com/index.php?forums/knife-reviews-testing.718/

</IfModule>
~
 
Last edited:
Having issues with my redirects as well, full friendly enabled:

Old profile:
http://www.bladeforums.com/forums/member.php/105215-Spark

New:
http://www.bladeforums.com/members/spark.105215/

Old thread:
/forums/showthread.php/1485279-We-will-be-changing-forums-software-in-the-next-48-72-hours

New:
/threads/we-will-be-changing-forums-software-in-the-next-48-72-hours.1485279/

Forumdisplay:
Old: /forums/forumdisplay.php/844-Service-amp-Support

New
http://www.bladeforums.com/categories/service-support.844/

.htaccess

Add these rules to the top of the .htaccess file in your web root (XF's .htaccess file):

Code:
RewriteEngine On

RewriteRule ^forums/member\.php/([0-9]+)-.*$ /members/$1/ [R=301,L]
RewriteRule ^forums/showthread\.php/([0-9]+)-.*$ /threads/$1/ [R=301,L]
RewriteRule ^forums/forumdisplay\.php/([0-9]+)-.*$ /categories/$1/ [R=301,L]
 
We applied the standard files and that took care of redirecting links like this:
Code:
http://www.thedentedhelmet.com/showthread.php?t=9861

Sadly, on the same site we also had "friendly" URLS like this:
Code:
http://www.thedentedhelmet.com/f23/affo-s-paint-list-airbrush-challenged-11819/

We have tried everything we know to do, but we can't seem to get the friendly URLs to redirect correctly.

At the moment it is redirecting the friendly URLS like this:
Code:
https://www.thedentedhelmet.com/forums/f23/affo-s-paint-list-airbrush-challenged-11819/

A nice start, but not what we need. Any help would be greatly appreciated.
 
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]
Thank you for these...They work great. only question, I've moved my XF install to root. I've updated the 301config, but the redirects only seem to work once I take out the /forums/ part of the url
 
@TheComputerGuy

The redirect files would need to remain at the old vB location, while the 301config.php file points to XF's new directory. If using those rewrite rules then you should update the XF paths in those rules as well.

If it's not working then please provide an example old and new thread URL (vB to XF) to confirm.
 
Hi all -

Moved from VB4 to Xen recently and I have most of my redirects working thanks to this thread... looking through my errors logs, however, it appears that I had an additional type of link out there that I wasn't aware of.

/vbulletin/threads/343394-***Forum-Upgrade-11-18-2017***
redirects correctly to
/xen/threads/343394/

however,
/vbulletin/threads/343394/
does not redirect and 404's

Current .htaccess:
RewriteRule ^index\.php$ /xen/threads/featured [R=301,L]
RewriteRule ^forum\.php$ /xen/threads/featured [R=301,L]
RewriteRule ^search\.php$ /xen/threads/featured [R=301,L]
RewriteRule ^usercp\.php$ /xen/threads/featured [R=301,L]
RewriteRule ^content/ /xen/threads/featured [R=301,L]
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]
 
Top Bottom