How can PHP code be integrated with mod_rewrite rules to achieve the desired URL structure?
To integrate PHP code with mod_rewrite rules to achieve a desired URL structure, you can use mod_rewrite to rewrite URLs to a PHP script that will handle the request and generate the appropriate content based on the URL parameters.
```php
RewriteEngine On
RewriteRule ^products/([0-9]+)/?$ product.php?id=$1 [NC,L]
```
In this example, the mod_rewrite rule will rewrite URLs like `example.com/products/123` to `example.com/product.php?id=123`, allowing the PHP script to retrieve the product information based on the ID provided in the URL.