Forum Moderators: phranque
http://mysiteurl/categories.php?catid=1
http://mysiteurl/products.php?prodid=1
http://mysiteurl/categories-1.html
http://mysiteurl/products-1.html
http://mysiteurl/categories-.html
http://mysiteurl/categories-abc.html
RewriteRule ^categories-([0-9]*)\.html$ categories.php?catid=$1
RewriteRule ^products-([0-9]*)\.html$ products.php?prodid=$1
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /categories\.php\?catid=([^\ ]+)\ HTTP/
RewriteRule ^categories\.php$ http://mysiteURL/categories-%1.html? [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /products\.php\?catid=([^\ ]+)\ HTTP/
RewriteRule ^products\.php$ http://mysiteURL/products-%1.html? [R=301,L]
^categories-([0-9]*)\.html$ allows for zero digits. Change the * to a + here and in the other rule. /categories\.php\?catid=([^\ ]+)\ /HTTP will fail if there are additional parameters. /categories\.php\?catid=([^&\ ]+)(&[^&\ ]+)*\ /HTTP or similar. RewriteRule for clarity. # comment before every block of code. You'll have forgotten what each bit of code is for by next week/month/year.