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?
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.
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]

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.