What are the potential security risks of replacing ModRewrite with PHP for URL redirection?

Replacing ModRewrite with PHP for URL redirection can introduce security risks such as potential vulnerabilities in the PHP code, increased server load due to PHP execution for every request, and the possibility of introducing bugs or errors in the redirection logic. To mitigate these risks, it is important to ensure that the PHP code is secure, efficient, and properly handles edge cases.

<?php
// Secure and efficient URL redirection using PHP
$redirectUrl = 'https://example.com/new-page';
header('Location: ' . $redirectUrl);
exit;
?>