1

I want to redirect visitors who get to my old phpbb forum URLs to my new URL structure.
http://mydomain.com/phpbb/viewtopic.php?f=$var1&t=$var2 (f=$var1, t=$var2 are integers)
to
http://mydomain.com/topic/$var2

My .htaccess mod_rewrite code:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^phpbb/viewtopic\.php\?f=\d+&t=(\d+)$ topic/$2 [L]
</IfModule>

But it doesn't work. How can I change the code that it works?

Shegit Brahm
  • 725
  • 2
  • 9
  • 22

2 Answers2

1

Add the following to the .htaccess in the root folder of your site.

RewriteEngine on
RewriteBase /

#place these two lines before any other rules in your .htacess
RewriteCond %{QUERY_STRING} (^|&)t=([0-9]+)(&|$) [NC]
RewriteRule ^phpbb/viewtopic\.php$ /topic/%2? [L,R,NC] 
Ulrich Palha
  • 9,411
  • 3
  • 25
  • 31
0
RewriteEngine on
RewriteBase   /
RewriteCond   %{QUERY_STRING}        \bt=([0-9]+)
RewriteRule   ^phpbb/viewtopic\.php  topic/%1?    [R=301,NC,L]
TerryE
  • 10,724
  • 5
  • 26
  • 48