What are best practices for handling URLs in PHP systems when rewriting them?

When rewriting URLs in PHP systems, it is important to ensure that the rewritten URLs are clean, user-friendly, and SEO-friendly. One best practice is to use mod_rewrite in Apache to rewrite URLs in a way that hides the underlying script file. This can be achieved by creating a .htaccess file in the root directory of your project and using RewriteRule directives to map URLs to the corresponding PHP scripts.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]