Redirect Entire Website without losing Google Ranks

Client has purchased a shorter version of their domain name,  old one was and new one is

I need to redirect the entire site (apache/php) using .htacess without losing google ranks. All urls will be exactly  the same, the only thing changing is the main web address above.

Can I use a simple 301 or will I need a Mod rewrite to make sure the google ranks remain in tact?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

301 redirects will make sure that google and other search engines know that the site has moved and will start indexing the new site from then on without losing ranks.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
For php you can use :

Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location:" );
mcpilot1Author Commented:
One small issue however - my home page is an html page. The rest of the site is php. I suppose I can swap index.html for index.php since it's a basic html page, and add the php code as above?
oh ok .htaccess.

If you run a linux server you will need the Apache Mod-Rewrite module enabled. Then you can make a .htaccess file in the root / of your site:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*)$1 [R=301,L]

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.