Moving old domain to a new domain using the same hosting account
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} www.?old.com$ [NC]
RewriteRule .* http://www.new.com%{REQUEST_URI} [R=301,L]
With this setup, every request for your olddomain.com is permanently redirected (with 301 code) to newdomain.com
Change your domain name and redirect the old domain to the new one
This is one, of the best ways to change a domain name. Simply set up your new domain test if everything is working fine and then add a redirection from your old domain (account) to your new domain but also keep your old domain and account for a few months with the redirection on. It’s even better if you do that for a year
.
When you are sure that the new domain is indexed on search engines, double-check if there are no links pointing to the old domain and then you can use your old domain for something else (not the same content) it’s not advised to let that domain name go since someone else might take advantage the reputation your old domain still hols.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} www.yourdomain.com$[OR]
RewriteCond %{HTTP_HOST} yourdomain.com$
RewriteRule .*$ http://www.yourNEWdomain.com/$1 [R=301,L]
SEO tips with .htaccess
One problem you have to deal with is double links, this is so important that in many cases your website faces issues with search engines because of the double content, and this could be like gozenhost.com/page.html and www.gozenhost.com/page.html .
If you don’t like the www and you prefer to use http://gozenhost.com links then you can reverse the setting like this:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} www.gozenhost.com
RewriteRule .* http://gozenhost.com/$1 [R=301,L]
You can test this very easily, just try it on your browser (make sure the cache of your browser is cleared in order to see the results immediately.