How can URL rewriting be used to optimize the performance of a PHP application that generates static pages from database entries?

URL rewriting can be used to optimize the performance of a PHP application by allowing the server to serve static pages generated from database entries without having to process PHP scripts each time a page is requested. This can significantly reduce server load and improve response times for users.

```php
RewriteEngine On
RewriteRule ^page/([0-9]+)$ generate_static_page.php?id=$1 [L]
```

In this example, the URL rewriting rule will redirect requests for URLs like "example.com/page/123" to a PHP script called "generate_static_page.php" with the corresponding ID parameter. The PHP script can then retrieve the database entry for that ID and generate a static page, which can be served directly by the server without the need to process PHP scripts on subsequent requests.