Of course you can use the DNS at the REGISTRAR (GoDaddy, Enom, etc) level but what if you have access to the server but not the domain?
Two files are needed:
- index.php
- .htaccess (don't forget the leading '.' and there are no extensions)
The contents of the index.php file to redirect to the new web site:
header('Location: https://foo.tld');?>
The contents of the .htacess file to redirect any phantom links to the index page:
Options +SymLinksIfOwnerMatch RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]