Can't trigger the redirect

I need to redirect the URL like viewforum.php?f=123 in Apache main conf file, I have tried every format I can think of, but it still doesn’t trigger it. I have something very similar which works well, the only difference is that one doesn’t have the question mark. Here is what I have tried:

RewriteEngine On
RewriteRule viewforum\.php\?f=([0-9]+) http://www.newdomain.com/phpbb2vb.php?oldforumid=$1 [L,R=301]
RewriteRule ^viewforum\.php\?f=([0-9]+)$ http://www.newdomain.com/phpbb2vb.php?oldforumid=$1 [L,R=301]
RewriteRule ^/viewforum\.php\?f=([0-9]+)$ http://www.newdomain.com/phpbb2vb.php?oldforumid=$1 [L,R=301]
RewriteRule ^/viewforum.php?f=([0-9]+)$ http://www.newdomain.com/phpbb2vb.php?oldforumid=$1 [L,R=301]
RewriteRule ^/viewforum.php/?f=([0-9]+)$ http://www.newdomain.com/phpbb2vb.php?oldforumid=$1 [L,R=301]

And other possible combinations.

None of them worked, I have worked on this since yesterday. :confused: Any help would be greatly appreciated.

h_s,

You’re joking, aren’t you?

A RewriteRule cannot access a query string; it can only retain, add to or delete a query string but it cannot gain access to a pre-existing query string!

IMHO, you, too, could benefit (as members have for years) by reading the tutorial article linked in my signature (much of which has been turned into the second sticky thread … linked where you initialted this thread). In fact, I believe you’ll find the code you need there (signature link) to perform this task.

Regards,

DK

Thanks, David, I will study the links in you signature.

It worked after removing the query string. Thanks again.