Simple rewrite help

I’m trying to get https://www.example.com/topic.asp?ARCHIVE=&TOPIC_ID=5747

to

https://www.example.com/showthread.php?t=5747

Here is my attempt, but it doesn’t redirect

RewriteCond %{REQUEST_URI} ^/topic.asp$
RewriteCond %{QUERY_STRING} ^TOPIC_ID=([0-9]+)$
RewriteRule ^(.*)$ https://www.example.com/showthread.php?t=%1 [R=301,L]

Most likely this condition is failing because you’re requiring TOPIC_ID to start at the beginning of the string, but there’s ARCHIVE= in front. We can change it to matcher either the start of the string or an ampersand, and same for the end.

RewriteCond %{QUERY_STRING} color=red[/color]TOPIC_ID=([0-9]+)color=red[/color]

1 Like

that works, thanks!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.