How can mod_rewrite be used to create user-friendly URLs in PHP?
Mod_rewrite can be used in PHP to create user-friendly URLs by rewriting URLs in a more readable format. This can help improve SEO, make URLs easier to remember, and enhance the overall user experience. By using mod_rewrite rules in a .htaccess file, you can map user-friendly URLs to the actual PHP files or scripts on the server.
```php
RewriteEngine On
RewriteRule ^products/([0-9]+)/?$ product.php?id=$1 [NC,L]
```
In this example, the mod_rewrite rule will rewrite a URL like "example.com/products/123" to "example.com/product.php?id=123". This way, users see a user-friendly URL while the server processes the request correctly.