vBulletin 4.x URL Redirection

vBulletin 4.x URL Redirection 1.0.0

No permission to download
@BamaStangGuy

Hmm. Try this to avoid any conflicts:

Rich (BB 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 500 default
 
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^politicaljack\.com [NC]
    RewriteRule (.*) http://www.politicaljack.com/$1 [L,R=301]
 
    #make exception for XF's thread URL format
    RewriteRule ^threads/[^\.]+\.[0-9]+/ - [S=1]
    #redirect vB's thread URL format
    RewriteRule ^threads/([0-9]+)-.*$ /threads/$1? [R=301,L]

    #    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>
AuthName "xenForo Test Bed"
AuthUserFile "/home/politics/.htpasswds/public_html/xenforo/passwd"

That should work to avoid any conflicts with the redirects.
 
@BamaStangGuy

Hmm. Try this to avoid any conflicts:

Rich (BB 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 500 default

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^politicaljack\.com [NC]
    RewriteRule (.*) http://www.politicaljack.com/$1 [L,R=301]

    #make exception for XF's thread URL format
    RewriteRule ^threads/[^\.]+\.[0-9]+/ - [S=1]
    #redirect vB's thread URL format
    RewriteRule ^threads/([0-9]+)-.*$ /threads/$1? [R=301,L]

    #    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>
AuthName "xenForo Test Bed"
AuthUserFile "/home/politics/.htpasswds/public_html/xenforo/passwd"

That should work to avoid any conflicts with the redirects.

You are awesome man. The urls work now.
 
I think there might be a bug with forumdisplay.php. It won't rewrite the URL correctly if the the node type is a category.

Let say the category is named "Test" for forumdisplay?f=1 in VB4. Now after the import to XF, it has a newID of 3. When the url gets rewritten, it will turn out like this and it won't work: http://www.site.com/forums/3/, when it should've been http://www.site.com/categories/Test.3/

Does anyone know how to fix this? I feel like it just need a simple if statement to determine if the node type is a category or a forum, which should be inserted somewhere in:

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

    if ($newId = $importModel->mapNodeId($input['f']))
    {
        $target = XenForo_Link::buildPublicLink('canonical:forums', array('node_id' => $newId));
    }
}

Just to test that category, I tried changing from canonical:forums to canonical:categories to assume it detected a category, but it spits me back errors, which is:


An exception occurred: Undefined index: depth in /home/username/public_html/library/XenForo/Route/Prefix/Categories.php on line 35

  1. XenForo_Application::handlePhpError() in /home/username/public_html/library/XenForo/Route/Prefix/Categories.php at line 35
  2. XenForo_Route_Prefix_Categories->buildLink() in /home/username/public_html/library/XenForo/Link.php at line 331
  3. XenForo_Link::_buildLink() in /home/username/public_html/library/XenForo/Link.php at line 81
  4. XenForo_Link::buildPublicLink() in /home/username/public_html/forums/forumdisplay.php at line 34
 
Last edited:
@DJ XtAzY

Category links need a depth specified, like so:

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

    if ($newId = $importModel->mapNodeId($input['f']))
    {
        $target = XenForo_Link::buildPublicLink('canonical:forums', array('node_id' => $newId, 'depth' => 1));
    }
}

This sets an arbitrary depth, but category links are canonicalized so it should come out correct.
 
Actually almost all my links work. How do I rewrite from:

forums/1938479-post1.html

to:

forums/showpost.php?p=1938479&postcount=1

This is the last of vbseo rules I want to convert. Thanks!

EDIT:

I already have these default rules for showthread:
RewriteRule [^/]+/([\d]+)-.+-([\d]+).html /forums/showthread.php?t=$1&page=$2 [NC,L]
RewriteRule [^/]+/([\d]+)-.+.html /forums/showthread.php?t=$1 [NC,L]

I came up with this rule myself:
RewriteRule [^/]+/([\d]+)-post([\d]+).html /forums/showpost.php?p=$1&postcount=$2 [NC,L]

I'm not sure if those bolded rules will conflict with each other.
 
Last edited:
Is there a way to include archive ?

Everything is working fine except that, so I am looking a way to include archive and send it to the original thread itself.

Posible ?

This are my main 404 URLs

Code:
http://site.com/forums/archive/index.php/t-5897.html?s=760eb1d9fbf101e0a0d552fa2c7385da
http://site.com/forums/memberlist.php?&pp=30&order=desc&sort=username&page=52
http://site.com/forums/calendar.php?do=getinfo&day=2012-11-19&c=1

My forum now is in forum/ without the s, so redirecting to the main forum is ok.

How can I do it ?
 
Last edited:
@polle

Since the id is the same you can use a rewrite rule.

Add this to the .htaccess file in the old /forums directory:

Code:
RewriteEngine On

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

Since the id is the same you can use a rewrite rule.

Add this to the .htaccess file in the old /forums directory:

Code:
RewriteEngine On

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

Thank you Jake!

One question, I have no old directory and I would like to avoid the creation of it.
How should the rule needs to be if I place it in my domain root htaccess ?

Code:
RewriteEngine On

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

Is that correct ?
 

Thank you.

In this 2 ones how can I redirect them to the main /forum directory?

Code:
http://site.com/forums/memberlist.php?&pp=30&order=desc&sort=username&page=52
http://site.com/forums/calendar.php?do=getinfo&day=2012-11-19&c=1
 
Looks like Jake is the man here. Maybe he can spare a moment to help me. Not sure it is doable though...

Migrated VB4.2 with VBSEO in vb dir to XF in xf dir successfully.
Installed the vb4 url redirection script

Code:
Old VB path:
http://www.domain.com/vb/news-books-today-culture/44669-scandal-season.html

Equivalent thread in XF
http://www.domain.com/xf/index.php?threads/scandal-season.44669/

Is a redirect doable? Help write?
What folder should it go in?
Remove everything else in that specific .htaccess file before adding?
Anything else I should watch out for/do?

Appreciate the time.
 
Nope, false positive. Now its asking the browser what to do with the page:
Code:
application/x-httpd-php5 (44.3 KB
It worked there for a few pages/while.
Back to scouring for a solution...
 
Top Bottom