It’s recommend to make this redirection using the webserver host config files. It would be easier and you wouldn’t need to tweak OJS core.
If you host your journal using apache, you should create a .htaccess file in your www root folder adding the following:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) http://anotherdomain.com [R=301]
That should work.
You can still tweak OJS editing the OJS_root_folder/index.php file and adding a Location function at second line of the file, e.g.: