1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 simple php redirect scripts from vB4

Discussion in 'Installation, Upgrade, and Import Support' started by dougdirac, Sep 28, 2015.

  1. dougdirac

    dougdirac 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.

    Thanks!
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    If the ids are the same then you can use pure rewrite rules. If you provide an example old and new thread URL then I can provide exact instructions.
     
  3. dougdirac

    dougdirac Member

    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: Mar 8, 2016
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

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

    Code:
    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.
     

Share This Page