301 redirect with querystring problem

i just changed my bulletin board from vbulletin to smf everything is going well but now i need to create an .htaccess file to redirect my post url to the new one im trying to test it in xamp first but its not working.
here is the old link
i want redirect it to [URL=“http://localhost/smf/index.php/topic=11578”]
however this post id is varibale

RewriteEngine on
RewriteCond %{QUERY_STRING} ^t=([0-9]+)$
RewriteRule ^/zaman/vb/showthread.php$ /smf/index.php/topic=%1 [R=301,L]

i tried this code but its not working
any ideas, or ill lost more than 450k of indexed links in google
plz help
thanks in advance

In the example old URL you showed, the query string was just digits, not “t=” digits. Make sure you’re clear about what kind of query string you’re trying to match.

If this rewrite is in an htaccess file, which I suspect is the case, then you need to remove the leading slash from the pattern.

  1. COLOR=“#FF0000↩︎

thanks for quick reply
i did as u said sir so the code be like this

RewriteEngine on
RewriteCond %{QUERY_STRING} ^([0-9]+)$
RewriteRule ^zaman/vb/showthread.php$ /smf/index.php/topic=%1 [R=301,L]

its almost done but it gives me that adress
and this result (Numeric request keys are invalid.)
so i just need to remove the last (?11578)

Ahh, yes. The original query string is retained unless you define a new one in the substitution URL, which is as simple as just adding a question mark.

RewriteRule ^zaman/vb/showthread.php$ /smf/index.php/topic=%1? [R=301,L]

i tried to make as whaT u said sir bur nothing happend is there another solution?
because i dont know so much about htaccess and how it works

Can you show what your htaccess looks like now?

yes sir its like this

RewriteEngine on
RewriteCond %{QUERY_STRING} ^([0-9]+)$
RewriteRule ^zaman/vb/showthread.php$ /smf/index.php/topic=%1? [R=301,L]

I copy-pasted that code verbatim, and it ran exactly as expected. So there must be something else we’re not seeing.


^([0-9]+)$ is matching your entire query string. If you only want the digits, remove your start anchor (the ^).



its now working like a charm with both of u and here is the final code for who want

RewriteEngine on
RewriteCond %{QUERY_STRING} ([0-9]+)$
RewriteRule ^zaman/vb/showthread.php$ /smf/index.php/topic=%1? [R=301,L]

this code for who changing from vbulliten 4 to smf 2. offcourse u will not save all ur links but it help for the main posts
thank u for mr jeff and mr dklynn for their help
and thanks for all