Using Apache's mod_rewrite, we can move requests from an old domain to a new one very easily.
However - you may search on the internet and find this:
Redirect 301 / http://www.example.com/
THIS WILL NOT WORK.Certainly, in my experience, the original file that was requested was appended onto the new domain, for example if the user types:
www.foo.com/file1.html
Then they were being redirected to
www.bar.com/file1.html
file1.html was always being appended, and resulting in a 404 (as I had completely changed the structure of the site)
What you need is RewriteRule.
RewriteEngine on
RewriteRule (.*) http://www.[newdomain].com/ [R=301,L]
And everything works.
So, create your .htaccess file (note: no prefix - it has to be .htaccess, so you may need to create/rename the file on the server) in the root of the website.