What is the recommended method for rewriting URLs in PHP to create cleaner and more user-friendly URLs?
Creating cleaner and more user-friendly URLs in PHP can be achieved by using URL rewriting techniques. One common method is to rewrite URLs using Apache's mod_rewrite module in the .htaccess file. This allows for transforming URLs from dynamic query strings to more readable and SEO-friendly formats.
```php
RewriteEngine On
RewriteRule ^products/([0-9]+) /product.php?id=$1 [L]
```
This code snippet demonstrates how to rewrite a URL from `product.php?id=123` to `products/123`. This makes the URL more user-friendly and easier to understand.