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

XF 1.5 how to redirect from old forum to new xenforo

Discussion in 'Installation, Upgrade, and Import Support' started by octabrain, Jul 31, 2016.

  1. octabrain

    octabrain Member

    I'm trying to redirect the urls, as they were used by the old forum, to xenforo urls.

    The old forum has urls like this for forums for example:


    xenForo urls would look like this:


    So, I thought I could just write some rewrite conditions and rules for mod_rewrite and it would work. But it doesn't and not really sure what I'm doing wrong.
    I added these lines to the .htaccess in the xenforo directory:

    RewriteCond %{QUERY_STRING} ^forum-showtopics-(.*)$ [NC]
    RewriteRule index.php$ index.php?forums/%1/ [NC]

    But if I enter an old url like:


    I get this error: Route forum-showtopics-2/ could not be found.

    What am I doing wrong here?
  2. shabbirbhimani

    shabbirbhimani Active Member

    You should enter that redirect rules before the Xenforo provided rules in htaccess as once you are at index.php of Xenforo, it will not be redirected as the rule has L in it which means it is the last rule in the chain. Hope that helps.
  3. octabrain

    octabrain Member

    I put my rules before the xenForo rules already. That's when I get the problem.
    Last edited: Jul 31, 2016
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Try this:

    RewriteCond %{QUERY_STRING} ^forum-showtopics-(.*)$ [NC]
    RewriteRule index.php$ index.php?forums/%1/ [R=301,L]
    If that doesn't work then try this:

    RewriteCond %{QUERY_STRING} (^|\?)forum-showtopics-(.*)$ [NC]
    RewriteRule index.php$ index.php?forums/%2/ [R=301,L]
    I have learned to look for both ^ and ? as the beginning of a query string. This can depend on the web server.
    octabrain and shabbirbhimani like this.
  5. octabrain

    octabrain Member

    Thank you very much Jake.
    Adding '[R=301,L]' did the trick.

Share This Page