XF 1.5 simple php redirect scripts from vB4


Active member
I know about the resource here, but I was wondering if there were simpler scripts available. Since I preserved my thread/post indices, I don't need a database lookup table.

I'm thinking it would be cleaner with php files. Within the forum we're often linking to other threads or posts.

So for example showthread.php would have to handle the following:

Different ways of linking to a thread:

Linking to a specific page (important for a lot of our Google results):

[Note default posts per page on vB is 10 while in XF is 20. So page number should be calculated (N+1)/2 convert to integer.]

Linking to a specific post:

Last edited by a moderator:
Add these rules to the top of your .htaccess file in the web root:

RewriteEngine On

# thread redirect with page
RewriteRule ^showthread\.php/([0-9]+)-[^/]+/page([0-9]+)$ /XFpath/index.php?threads/$1/page-$2 [R=301,L]
# thread redirect
RewriteRule ^showthread\.php/([0-9]+)-.*$ /XFpath/index.php?threads/$1/ [R=301,L]
# thread redirect
RewriteCond %{QUERY_STRING} (^|\?)([0-9]+)-.*$
RewriteRule ^showthread\.php$ /XFpath/index.php?threads/%2/ [R=301,L]
# thread redirect
RewriteCond %{QUERY_STRING} (^|\?)t=([0-9]+)$
RewriteRule ^showthread\.php$ /XFpath/index.php?threads/%2/ [R=301,L]
# post redirect
RewriteCond %{QUERY_STRING} (^|\?)p=([0-9]+)($|&)
RewriteRule ^showthread\.php /XFpath/index.php?posts/%2/ [R=301,L]

That should do it.

...but the page redirect does assume the page number stays the same. Ideally the posts per page should be the same. If you want to keep it different then yes... a PHP script would be needed to do the calculation.
Top Bottom