What is the best practice for URL rewriting in PHP using htaccess?

URL rewriting in PHP using htaccess is a common practice to create clean and user-friendly URLs for better SEO and usability. To achieve this, you can use the mod_rewrite module in Apache to rewrite URLs based on certain conditions. By creating a .htaccess file in your root directory and defining rewrite rules, you can customize the URLs to match your desired format.

RewriteEngine On
RewriteRule ^products/([0-9]+)/?$ product.php?id=$1 [NC,L]