How can mod_rewrite be used to enhance security and control access to download files in PHP?

To enhance security and control access to download files in PHP, you can use mod_rewrite to rewrite URLs and restrict access based on certain conditions. By using mod_rewrite, you can hide the actual file paths and control who can access the files by setting specific rules in the .htaccess file.

```php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^downloads/(.*)$ download.php?file=$1 [L]
```

In this code snippet, the mod_rewrite rules are set to rewrite URLs that start with "downloads/" to the download.php file, passing the requested file as a parameter. This allows you to control access to the download files through the download.php script and implement security measures as needed.