mod_rewrite for moving a phpBB Forum
Recently I split off 3 forums from an old site and created them fresh on the new site (pretty easy to do, just dupe the DB and nuke the ones you don’t need).
Here’s the mod_rewrite I used to redirect the links for *just* those 3 forums to the new site:
In the .htaccess file of the forum’s root directory:
RewriteEngine on
RewriteCond %{QUERY_STRING} f=(26|27|29)
RewriteRule ^viewforum\.php "http\:\/\/community.geospike.com\/viewforum.php" [R=301,L]
RewriteCond %{QUERY_STRING} f=(26|27|29)
RewriteRule ^viewtopic\.php "http\:\/\/community.geospike.com\/viewtopic.php" [R=301,L]
The RewriteCond ensures the redirection only applies to the 3 forum IDs that I wanted. The rewrite rule matchs the viewforum and viewtopic links to the new forum, with a “permanent” 301 redirect. As the RewriteRule regex is not terminated with “$”, all the parameters are sent to the new URL.
Easy.
