Who else has converted from phpBB? How did you deal with .htaccess redirects?

Paul B

XenForo moderator
Staff member
I'm converting tonight and just wondered how others are handling redirects.

First there's the issue of redirecting /forum to /community.
Presumably this will do the job?
RewriteRule ^forum\/$ "community\/" [R=301,L]

In addition, there are a few specific threads I would like to redirect but I couldn't seem to get it to work. I tried this:
RewriteRule ^forum\/viewtopic\.php\?f=51&t=822$ "http\:\/\/www\.mysite\.com\/community\/pages\/home\/" [R=301,L]

But it didn't work for some reason.

Has anyone else managed to redirect a specific thread in this way?
 
First there's the issue of redirecting /forum to /community.
Presumably this will do the job?
RewriteRule ^forum\/$ "community\/" [R=301,L]

You'd probably be better off with

Code:
RewriteRule ^forum(.*) community$1 [R=301]
or
Code:
RewriteRule ^forum(.*) community/ [R=301]

(most likely the latter if you're handling redirections manually)

In addition, there are a few specific threads I would like to redirect but I couldn't seem to get it to work. I tried this:
RewriteRule ^forum\/viewtopic\.php\?f=51&t=822$ "http\:\/\/www\.mysite\.com\/community\/pages\/home\/" [R=301,L]

But it didn't work for some reason.

Has anyone else managed to redirect a specific thread in this way?

RewriteRule doesn't support reading from the query string, you have to use a seperate RewriteCond line (this is why I prefer nginx :P - so much simpler to configure)

Code:
RewriteCond %{QUERY_STRING} ^f=51&t=822$
RewriteRule ^forum/viewtopic.php community/whatever [R=301,L]

You can also access regex backreferences from the RewriteCond in the RewriteRule using %1 rather than $1.
 
Many thanks DI, you're a life saver :)
There's one thread on my site which receives thousands of hits every month so I really didn't want to lose the traffic when converting.

RewriteRule doesn't support reading from the query string, you have to use a seperate RewriteCond line (this is why I prefer nginx :p - so much simpler to configure)

Does that have to come before the main forum rewrite or doesn't it matter?
 
Top Bottom