To redirect all pages from http://www.olddomain.com to http://www.newdomain.com in the domain root of your old domain create a .htaccess file and paste the following code, changing the domain name:
RewriteRule (.*) http://www.newdomainname.com/$1 [R=301,L]
Obviously this doesn't have to be .com, it can be anything. This makes the old pages go to the same address at the new domain, eg:
Would be sent to
I find it useful when a development site gets indexed.
If the development pages get indexed, when the site moves and I redirect all the pages, google has nearly all of the new site indexed a few days after it goes live.