How can the HTTP_REFERER be accessed in PHP when using a RewriteRule in .htaccess?

When using a RewriteRule in .htaccess to redirect requests, the HTTP_REFERER header may not be passed to the redirected page. To access the HTTP_REFERER in PHP, you can set a custom header in the RewriteRule to pass the referer information along with the request. Then, in the PHP code of the redirected page, you can retrieve the referer from the custom header. ```apache # .htaccess RewriteEngine On RewriteRule ^example$ example.php [L,E=HTTP_REFERER:%{HTTP_REFERER}] ```

// example.php
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
echo $referer;