XF 1.5 how to redirect from old forum to new xenforo


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?
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.
Try this:

Rich (BB code):
RewriteCond %{QUERY_STRING} ^forum-showtopics-(.*)$ [NC]
RewriteRule index.php$ index.php?forums/%1/ [R=301,L]

If that doesn't work then try this:

Rich (BB code):
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.
Top Bottom