XF 1.5 how to redirect from old forum to new xenforo

octabrain

Member
Hi,
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:

http://forum.website.com/index.php?forum-showtopics-{forum_id}

xenForo urls would look like this:

http://forum.website.com/index.php?forums/{forum_id}/

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:

http://forum.website.com/index.php?forum-showtopics-2

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.
 
Back
Top Bottom