What is the purpose of mod_rewrite in PHP and how can it be used to rewrite URLs?

The purpose of mod_rewrite in PHP is to rewrite URLs in a more user-friendly format or to redirect URLs to a different location. This can help improve SEO, make URLs more readable, and create cleaner URLs for users to interact with.

RewriteEngine On
RewriteRule ^old-url$ new-url [L]