vBulletin 4.x URL Redirection

vBulletin 4.x URL Redirection 1.0.0

No permission to download
@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.
Hi Jake, thanks, that did fix the second redirect issue I mentioned, but not the first. This URL: http://www.domain.com/forum/showthread.php?44259 still redirects to the forum home, not to http://www.domain.com/forum/threads/44259. Can you please assist with this redirection as well? Much appreciated!
 
Hi Jake, thanks, that did fix the second redirect issue I mentioned, but not the first. This URL: http://www.domain.com/forum/showthread.php?44259 still redirects to the forum home, not to http://www.domain.com/forum/threads/44259. Can you please assist with this redirection as well? Much appreciated!

Amended:

Code:
RewriteEngine On

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

Code:
RewriteEngine On

# post redirect
RewriteCond %{QUERY_STRING} (^|&|\?)p=([0-9]+)($|&)
RewriteRule ^showthread\.php$ /forum/posts/%2/? [R=301,L]
# thread redirect
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)$
RewriteRule ^showthread\.php$ /forum/threads/%2/? [R=301,L]
That doesn't seem to have solved the issue, as http://www.domain.com/forum/showthread.php?44159 is still redirecting to the forum home. Here is the full htaccess, what do you recommend I change? Thanks.
Code:
Options +FollowSymLinks
RewriteEngine On
# post redirect
RewriteCond %{QUERY_STRING} (^|&|\?)p=([0-9]+)($|&)
RewriteRule ^showthread\.php$ /forum/posts/%2/? [R=301,L]
# thread redirect
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)$
RewriteRule ^showthread\.php$ /forum/threads/%2/? [R=301,L]
#RewriteBase /forum
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*) https://www.domain.com/forum/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ https://www.domain.com/forum/$1 [R=permanent,L]
RewriteRule ^(.*)/(styleid=(.*))$ showthread.php?&%{QUERY_STRING} [L]
RewriteRule ^(.*)/(showthread\.php)$ showthread.php?&%{QUERY_STRING} [L]
RewriteRule ^(.*)/t-(.*)-(.*)-new.html showthread.php?t=$3&goto=newpost&%{QUERY_STRING} [L]
RewriteRule ^(.*)/t-(.*)-(.*)-last.html showthread.php?t=$3&goto=lastpost&%{QUERY_STRING} [L]
RewriteRule ^(.*)/t-(.*)-(.*)-print.html/(.*)$ printthread.php?t=$3&%{QUERY_STRING}&is_vrewrite=yes [L]
RewriteRule ^(.*)/t-(.*)-(.*)-print.html printthread.php?t=$3&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^(.*)/t-(.*)-(.*)-nextnewest.html showthread.php?t=$3&goto=nextnewest&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^(.*)/t-(.*)-(.*)-nextoldest.html showthread.php?t=$3&goto=nextoldest&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^p-(.*)-post(.*)/postcount(.*).html showpost.php?p=$2&postcount=$3&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^(.*)/t-(.*)-(.*)-page(.*).html showthread.php?t=$3&page=$4&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^(.*)/t-(.*)-(.*)/page(.*).html showthread.php?t=$3&page=$4&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^(.*)/t-(.*)-(.*).html/(.*)$ showthread.php?t=$3&%{QUERY_STRING}&is_vrewrite=yes [L]
RewriteRule ^(.*)/t-(.*)-(.*).html showthread.php?t=$3&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^f-(.*)-(.*)/misc\.php$ misc.php?&%{QUERY_STRING}&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^members/(.*)-(.*).html member.php?u=$2&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^u-(.*)-(.*).html(.*) member.php?u=$2&is_vrewrite=yes&%{QUERY_STRING}$3 [L]
RewriteRule ^u-(.*)-(.*).html member.php?u=$2&is_vrewrite=yes&%{QUERY_STRING} [L]
RewriteRule ^f-(.*)-(.*)/page(.*).html/(.*)$ forumdisplay.php?f=$2&&page=$3%{QUERY_STRING}&is_vrewrite=yes [L]
RewriteRule ^f-(.*)-(.*)/(.*)$ forumdisplay.php?f=$2&&%{QUERY_STRING}&is_vrewrite=yes [L]
RewriteRule ^f-(.*)-(.*)/$ forumdisplay.php?f=$2&%{QUERY_STRING}&is_vrewrite=yes [L]
RewriteRule ^search-(.*).html$ search.php?do=$1 [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 500 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 /forum

    #    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>
 
Has anyone used a setup of VB 4.x URL redirect scripts for two different vb's merged into one xenforo.

I have one set of forums redirect from the old url (domain.com)/maxcon_forums/xxxx working fine with the archived table set in the main redirect files.

Now I am in progressing on merging in another forum which was previously located in /forums and going to archived the tables to a new entry.

So my question is if i setup another set of redirect files in the old directory with the new archived sql tablename, will both sets work without problems?

Thanks.
 
So my question is if i setup another set of redirect files in the old directory with the new archived sql tablename, will both sets work without problems?

Yes. Both are data driven through the 301config.php file. They will both work using their own settings from the 301config.php file.
 
According to the instructions, I just need to upload the redirect scripts for Basic urls? Nothing needs to be added to the htaccess file, is that correct?
 
According to the instructions, I just need to upload the redirect scripts for Basic urls? Nothing needs to be added to the htaccess file, is that correct?

Correct. Basic vB URLs such as showthread.php?t=1 do not require any htaccess files, just the PHP redirect scripts.
 
Hi Jake,

basic vb4(cms) url redirects seem to work except for this three.

1) redirecting the imported vb4 CMS Suite articles that xf has now in "blog comments" forum,
vb4 CMS Articles Home Page:
http://mimguild.com/content.php
redirects now to "Route content.php/ could not be found."
http://mimguild.com/content.php
should redirect to:
http://mimguild.com/

another Article example,
vb4 Article:
http://mimguild.com/content.php/132-Aten-Ha-Ra-down!
xf redirects now to "Route content.php/132-Aten-Ha-Ra-down! could not be found.":
http://mimguild.com/content.php/132-Aten-Ha-Ra-down!
xf currently shows the Article/Thread:
http://mimguild.com/threads/aten-ha-ra-down.12272/


2) vb4 Forum Categorys used to be Pages that displayed the Subforums,

Original vb4 Forum category:
http://mimguild.com/forumdisplay.php/4-Magus-Imperialis-Magicus
redirects with "The requested forum could not be found." to:
http://mimguild.com/forums/4/
it should redirect to here:
http://mimguild.com/forums/#magus-imperialis-magicus.4


3) Link to a specific post in a thread,
vb4 link:
http://mimguild.com/showthread.php/1255-Guild-History-Info-about-MIM?p=21810&viewfull=1#post21810
xf now opens the right thread but does not jump / scroll to the post:
http://mimguild.com/threads/guild-history-info-about-mim.1255/#post-21810

Thanks.
 
Last edited:
Have you changed the directory structure of those two

It looks like the first one was maybe a vB CMS article but is now a xenforo thread.

If that is the case just use individual 301 redirects
 
I was tired when i made the post, sorry. I just edited the spoiler and fixed the wrong link.
Yes it was a vb4 CMS from which i migrated and used [TH] vBulletin 4 CMS Importer by ThemeHouse to import my vb4 CMS Articles to the "blog comments" forum as threads.
I am also using XenPorta 2 now to promote the threads from.
 
@Laetos

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

Code:
RewriteEngine On

RewriteRule ^content\.php$ /? [R=301,L]

To redirect the individual articles would require an id map from the vB article ids to the XF thread ids. I don't think the importer does this for CMS articles because it sees them only as threads in vB. This requires some custom programming to map the thread ids to the article ids.

2) That's a category, not a forum. To avoid the bad redirect you would have to modify the forumdisplay.php redirect script to check the node type.

3) The showthread.php script gives priority to the thread redirect before it tries the specific post. If you switch around this if-else-if to do posts first then it should work:

Code:
if ($input['t'])
{
	if ($newId = $importModel->mapThreadId($input['t']))
	{
		$target = XenForo_Link::buildPublicLink('canonical:threads', array('thread_id' => $newId));
	}
}
else if ($input['p'])
{
	$newId = $importModel->mapPostId($input['p']);
	if ($newId)
	{
		$target = XenForo_Link::buildPublicLink('canonical:posts', array('post_id' => $newId));
	}
}
 
1) for some reason i thought the importer would utilize the 'archived_import_log' that i am using in the 301config.php and that articles would be able to get mapped to the new threads easily, my bad.

2) i tried this by adding ", 'depth' => 1" which i found in this post but had no luck
https://xenforo.com/community/threads/vbulletin-4-x-url-redirection.26935/page-2#post-559431

3) the switcheru of t/p, mapThreadId/mapPostId, threads/posts, thread_id/post_id did not work, used the showthread.php from the "vb-301-v7-2" package and this works jumping to post works now.
 
Question regarding the migration of vB4 (with DBSEO installed) to XF.
The current .htaccess file read as follows:

<IfModule mod_rewrite.c>
RewriteEngine On

# If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your vBulletin directory.
RewriteBase /forums/

# If you are having problems with the rewrite from content/ to content.php, uncomment this line to turn MultiViews off.
#Options -MultiViews

RewriteCond %{REQUEST_URI} !(admincp/|dbseocp/|modcp/|cron|mobiquo|forumrunner|api\.php|reviewpost/|classifieds/|photopost/)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ dbseo.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|dbseocp|modcp|clientscript|cpstyles|images|reviewpost|classifieds|photopost)/
RewriteRule ^(.+)$ dbseo.php [L,QSA]
</IfModule>

Should I need to do anything 'extra' as concerns the DBSEO installation?
Or will this redirection script work right out-of-box?
Thanks,

J.
 
So - I'm apparently stuck on stupid and cannot figure this redirect thing out. I see @Jake Bunce that you've helped a few people in this thread. Could you help me as well? I'd certainly appreciate your help or anyone who can suggest what I can do to rewrite these urls from a recent vB4 to XF conversion.

Okay. Here are the details:
vBadvanced installed in the root directory - vBulletin installed in "forums" directory - PhotoPost Pro and DBSEO installed.
Current XenPorta2 installed with XF in root directory - articles/ as Index Page Route with XFMG installed.

Root directory .htaccess file:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
AddType application/x-httpd-php .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

RewriteEngine On
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://sitename.com/$1 [R=301,L]

Forums directory .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On

# If you are having problems or are using VirtualDocumentRoot, uncomment this line and set it to your vBulletin directory.
RewriteBase /forums/

# If you are having problems with the rewrite from content/ to content.php, uncomment this line to turn MultiViews off.
#Options -MultiViews

RewriteCond %{REQUEST_URI} !(admincp/|dbseocp/|modcp/|cron|mobiquo|forumrunner|api\.php|reviewpost/|classifieds/|photopost/)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ dbseo.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|dbseocp|modcp|clientscript|cpstyles|images|reviewpost|classifieds|photopost)/
RewriteRule ^(.+)$ dbseo.php [L,QSA]
</IfModule>

URL Structure:
Old VB4: https://sitename.com/forums/dimensional-signs.html
New XF: https://sitename.com/forums/dimensional-signs.166/

Old VB4: https://sitename.com/forums/polls/137068-lamination-roll.html
NewXF: https://sitename.com/threads/lamination-roll.137068/ (am I doing something wrong here? should 'forums' be in the url?)

I'm having a terrible time grasping the concept of this .htaccess redirect/rewrite stuff. Probably the fact that I've been up for 48+ hours with only a 2-hour nap earlier this afternoon probably has something to do with it. But eh... Who we kidding - the code reads as if Greek to me at this particular moment LOL..

Anyway - @Jake Bunce -- I would very much appreciate if you could help me fix it so that we can get the correct code in place and not loose any linkjuice in the various search engines. Again - I'm not versed in code much - so if you can give detailed instruction - it would be great! Thanks for the consideration.

J.
 
So - I'm apparently stuck on stupid and cannot figure this redirect thing out. I see @Jake Bunce that you've helped a few people in this thread. Could you help me as well? I'd certainly appreciate your help or anyone who can suggest what I can do to rewrite these urls from a recent vB4 to XF conversion.

Okay. Here are the details:
vBadvanced installed in the root directory - vBulletin installed in "forums" directory - PhotoPost Pro and DBSEO installed.
Current XenPorta2 installed with XF in root directory - articles/ as Index Page Route with XFMG installed.

Root directory .htaccess file:


Forums directory .htaccess file:


URL Structure:
Old VB4: https://sitename.com/forums/dimensional-signs.html
New XF: https://sitename.com/forums/dimensional-signs.166/

Old VB4: https://sitename.com/forums/polls/137068-lamination-roll.html
NewXF: https://sitename.com/threads/lamination-roll.137068/ (am I doing something wrong here? should 'forums' be in the url?)

I'm having a terrible time grasping the concept of this .htaccess redirect/rewrite stuff. Probably the fact that I've been up for 48+ hours with only a 2-hour nap earlier this afternoon probably has something to do with it. But eh... Who we kidding - the code reads as if Greek to me at this particular moment LOL..

Anyway - @Jake Bunce -- I would very much appreciate if you could help me fix it so that we can get the correct code in place and not loose any linkjuice in the various search engines. Again - I'm not versed in code much - so if you can give detailed instruction - it would be great! Thanks for the consideration.

J.
Can anyone help with this please?
I'm willing to pay a small premium for the correct code here.
Thanks!

J.
 
@MsJacquiiC

The forum URL can't be redirected because it doesn't contain an id.

For the thread URL, add these rules to the top of the .htaccess file in the old /forums directory:

Code:
RewriteEngine On

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

The forum URL can't be redirected because it doesn't contain an id.

For the thread URL, add these rules to the top of the .htaccess file in the old /forums directory:

Code:
RewriteEngine On

RewriteRule ^[^/]+/([0-9]+)-[^\./]+\.html$ /threads/$1/ [R=301,L]
You're LATE to the party my friend :giggle:
Thanks for your reply and hope you're doing well. I had a colleague on TAZ reach out and has been extremely kind in providing his assistance. So all is good. The urls are redirecting in Google and Bing just fine now.

Thanks!

J.
 
Top Bottom