What is the purpose of using mode-rewrite in PHP?

When using mod_rewrite in PHP, the purpose is to rewrite URLs in a more user-friendly and search engine-friendly format. This allows for cleaner URLs that are easier to read and remember, as well as improving SEO by including relevant keywords in the URL structure. Mod_rewrite also helps in redirecting URLs to different pages or handling dynamic URLs more effectively.

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