Redirect Dynamic URL to Static Link and Redirect old to new no loop error

I spent such a huge amount of time trying to find the answer to this problem, and different servers might behave differently, I spent a long time trying so many different variations and combinations

In the end I couldn’t get it to work, and so I renamed the PHP file that was generating the pages:

EG:

  • I want
  • https://pushkaCom.com/product.php?id=6
  • to redirect to
  • https://pushkaCom.com/products/toasters/

rename product.php to p-product.php

RewriteCond %{QUERY_STRING} ^id=6$
RewriteRule ^product\.php(.*)$ https://pushkaCom.com/products/toasters/? [R=301,L]
RewriteRule ^products/toasters/$ p-product.php?id=6 [NC,L]

This was coming up as an infinite loop…

RewriteEngine On
[R=301,L]
RewriteCond %{QUERY_STRING} ^id=6$
RewriteRule ^product\.php$ https://pushkaCom.com/products/toasters/? [R=301,L]

RewriteEngine on
RewriteRule ^products/toasters/$ product.php?id=6 {{{maybe add  [R=301,L]  and switch the two?? }}}