What are best practices for handling relative links in PHP applications with mod_rewrite?

When using mod_rewrite in PHP applications, relative links may not work as expected due to the rewritten URLs. To handle this issue, it is best practice to use the `$_SERVER['REQUEST_URI']` variable to dynamically generate the base URL for relative links.

```php
$base_url = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/');
```

This code snippet retrieves the directory path of the current script and removes any trailing slashes to create the base URL for relative links. You can then use this `$base_url` variable to prepend to any relative links in your PHP application.