vBulletin 4.x URL Redirection

vBulletin 4.x URL Redirection 1.0.0

No permission to download

TheLaw

Well-known member
OK - The instructions are difficult to follow. I'm using standard vb3 query strings after converting a vb4 site, same thread numbers. This is the only thing that works for redirecting threads. The other .htaccess directives seem to be ignored and setting up the files for the redirect doesn't work. I am guessing it is because my XF install is in public_html (root) when my VB4 forum was in the /forums/ directory.

Code:
RewriteCond %{QUERY_STRING} (^|\?)t=([0-9]+)($|&)
RewriteRule ^forums/showthread\.php$ /threads/%2/? [R=301,L]
RewriteRule ^[^/]+/([0-9]+)-.+-([0-9]+)\.html$ /threads/$1/page-$2 [R=301,L]
RewriteRule ^[^/]+/([0-9]+)-[^\.]+\.html$ /threads/$1/ [R=301,L]
This only works for threads. Tried the following:

Code:
## to redirect forums (forumdisplay using f)
RewriteCond %{QUERY_STRING} ^f=([0-9]+)$
RewriteRule ^forumdisplay\.php$ http://www.thelaw.com/forums/.%1? [L,R=301]
## to redirect threads (showthread using t=)
RewriteCond %{QUERY_STRING} ^t=([0-9]+)$
RewriteRule ^showthread\.php$ http://www.thelaw.com/threads/.%1? [L,R=301]
## to redirect posts (showthread using p=)
RewriteCond %{QUERY_STRING} ^p=([0-9]+)$
RewriteRule ^showthread\.php$ http://www.thelaw.com/posts/.%1? [L,R=301]
This doesn't work at all. Can't explain why. Don't get it. The above doesn't work when substituting out forums...
 
Last edited:

TheLaw

Well-known member
OK - For anyone in need, this is what worked for me after rewriting it with my piddling regex skills:

Code:
RewriteEngine on
# This is to redirect your site to use www - always good to have this or the reverse for non-www
RewriteCond %{HTTP_HOST} ^myste.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]

# thread
RewriteCond %{QUERY_STRING} (^|\?)t=([0-9]+)($|&)
RewriteRule ^forums/showthread\.php$ /threads/%2/? [R=301,L]
RewriteRule ^[^/]+/([0-9]+)-.+-([0-9]+)\.html$ /threads/$1/page-$2 [R=301,L]
RewriteRule ^[^/]+/([0-9]+)-[^\.]+\.html$ /threads/$1/ [R=301,L]

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

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

# member
RewriteCond %{QUERY_STRING} (^|\?)u=([0-9]+)($|&)
RewriteRule ^forums/member\.php$ /members/%2/? [R=301,L]
 
I migrated my vbulletin 4.2 forum last night. I hadn't even considered url redirection. :eek:

Here's what I need to do:

Old url-

example.com/forums/showthread.php?11942-PSA-Site-Upgrades-Coming-Soon

New url-

example.com/forums/threads/psa-site-upgrades-coming-soon.11942/

I moved the old forum to a new directory last night. I run wordpress in the root directory. Not sure if either of those is relevant. I also need to use non www urls, too.

Here's the current xenforo 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]
</IfModule>
# MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^74.74.66.54
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
</IfModule>
Really hoping @Jake Bunce can set me straight. Really appreciate anyone's help.
 
OK - For anyone in need, this is what worked for me after rewriting it with my piddling regex skills:

Code:
RewriteEngine on
# This is to redirect your site to use www - always good to have this or the reverse for non-www
RewriteCond %{HTTP_HOST} ^myste.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]

# thread
RewriteCond %{QUERY_STRING} (^|\?)t=([0-9]+)($|&)
RewriteRule ^forums/showthread\.php$ /threads/%2/? [R=301,L]
RewriteRule ^[^/]+/([0-9]+)-.+-([0-9]+)\.html$ /threads/$1/page-$2 [R=301,L]
RewriteRule ^[^/]+/([0-9]+)-[^\.]+\.html$ /threads/$1/ [R=301,L]

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

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

# member
RewriteCond %{QUERY_STRING} (^|\?)u=([0-9]+)($|&)
RewriteRule ^forums/member\.php$ /members/%2/? [R=301,L]
Where did you put that exactly?
 

TheLaw

Well-known member
Where did you put that exactly?
Exactly. Did you reinstall in the forums directory? If you did, I imagine that everything here will be straightforward and won't require my comments as they are for installing in a directory other than the one you had vBulletin in prior. Good luck!
 
Exactly. Did you reinstall in the forums directory? If you did, I imagine that everything here will be straightforward and won't require my comments as they are for installing in a directory other than the one you had vBulletin in prior. Good luck!
Thanks! Yes I did. I just installed the 301 config and other files and all the old threads appear to be redirecting. :D

The old forum url does not redirect though. :confused: I also need www. to redirect to non www. I guess I can just add that into the /forums htaccess file?
 

TheLaw

Well-known member
Thanks! Yes I did. I just installed the 301 config and other files and all the old threads appear to be redirecting. :D
The old forum url does not redirect though. :confused: I also need www. to redirect to non www. I guess I can just add that into the /forums htaccess file?
What was it? You an mask the domain if you wish.
 
Hmm, I've got everything working except redirecting from forums/forum.php. I've tried the below in both the XF and the root htaccess with no luck.

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

just imported my vB4 into xF (overwrote all the xF data, so IDs are identical to vB).

Redirecting my old mod_rewrite urls works like a charm. But I had an old script which posted the new threads to twitter with the schema "www.site.com/showthread.php/1234?analyticsstuff". For the love of god, I can't figure out how to redirect those old links to the new /threads/ scheme.

Here's my current .htaccess

Code:
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
    RewriteBase /

    # redirect site.com to www.site.com
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [L,R=302]  
    
    #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]
    #make exception for XF's member URL format
    RewriteRule ^members/[^\.]+\.[0-9]+/ - [S=1]
    #redirect vB's member URL format
    RewriteRule ^members/([0-9]+)-.*$ /members/$1? [R=301,L]
    #make exception for XF's forums URL format
    RewriteRule ^forums/[^\.]+\.[0-9]+/ - [S=1]
    #redirect vB's forums URL format
    RewriteRule ^forums/([0-9]+)-.*$ /forums/$1? [R=301,L]
      
  
    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>
TL;DR
I need a solution for redirecting
to
 

Jake Bunce

XenForo moderator
Staff member

Joeychgo

Well-known member

Jake Bunce

XenForo moderator
Staff member
Hello,

I would like to use this redirection too on my forum but 2 points:
#1
Links like .../showthread.php/32058-... are not redirected whereas links like .../showthread.php?t=32058... are.
Is this normal?

#2
The corresponding id is not correct. That means that the redirection opens not the correct thread.
For example, thread #32058 is redirected to thread #32131 where it should be #31201.
I've understood the "matching" ids are in table 'archived_import_log', but how could it be that this is wrong?
Is there a way to re-generate it?

Thanks
 
Last edited:
Top