Whilst the .htaccess file may be used to provide temporary and permanent redirects to manage pages which have been deleted or moved, PHP also provides redirect methods.
Using PHP to redirect the browser may be a better option compared to htaccess if the server prevents the file from being overwritten, or indeed if its inaccessible.
Creating a plugin, or module, for one of the CMSs including a redirect within your code keeps everything under your control, unless you are able to rewrite the .htaccess file. But as above this may note be made available.
For php on Windows I added a redirect to the index.php file.
<? php header( "HTTP/1.1 301 Moved Permanently" ); header( "Location: http://www.example.com" ); exit(); ?>
Ensuring that the Header references are not capitalised maintains compatibility with older versions of php.
Where exit() is added to prevent further code execution on the page.
When testing the redirection I also wished to be able to double check the old URL. To do this I added typical HTML file basics. I was then able to comment the above php code and visit the page.
The php redirect code and additional HTML is given below.
<?
php
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://www.example.com" );
exit();
?>
<!DOCTYPE html>
<html lang="en-GB">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
Plain HTML website
</body>
</html>


