How to Change Your Domain While Keeping Your Search Engine Ranking

SMS Text

You’ve had your domain for a long time and it has served you well.  Today, though, you’re looking to expand your online business and the old domain just won’t do the trick.  You need something new, fresh and exciting and perhaps you’ve already registered the ideal name.

There’s just one problem.

Your old site has earned a good search engine ranking for your best keywords.  You’ve got tons of “link juice” to both give and receive – and you don’t want to lose that.

Keep in mind, we’re not just moving files or folders here – but moving an entire site to a new domain name without it affecting your ranking.  To do this, you’ll need two tools – .htaccess and mod_rewrite.

The following tips will work on a Linux/Unix server running Apache – which most web hosting companies use.  Before you start, check with your respective web host to ensure they support the mod_rewrite module and .htaccess.

What are .htaccess and mod_rewrite?

.htaccess is a file that tells the server how to handle certain things like security, error messages and, most importantly for us, redirection.  The mod_rewrite module lets you “rewrite” URLs.  It’s hosted on your web server so you won’t need to download or install anything.  This is the preferred way to redirect your site or pages to your new domain name without losing valuable ranking or back links.

To start, make sure your new domain is properly directed to your hosting account.  Upload your files from your old domain to the new one exactly as they appeared on the old domain.  Now it’s time to make your .htaccess file.  If you already have one on your new server, name it .htaccessBACKUP.  Don’t delete it in case you need to restore the old settings for any reason.

Open Notepad by going to Start > Accessories > Notepad or use another simple text editor of your choice.  Don’t use Microsoft Word or another word processing program though – they will automatically add an extension to the filename like .doc – which is what we don’t want.

In this new file, copy and paste the following:

RewriteEngine On

RewriteRule ^(.*)$$1 [R=301,L]

Replace “” with your actual new domain name. Then save the file as:


Ensure it doesn’t have an extension (like .txt) – you can do this by choosing “All Files” in the dropdown menu – like so:

Once you save the file, upload it to your root directory for your old domain name.  Try it out by typing in your old domain in your browser.  You should immediately be directed to the new site.  The old domain name will still show in the address bar.  To make sure you’re browsing the new site and not the old one, just right-click on an image and choose Properties.  The full image URL should be displayed with the new site URL.

It Worked! – Now What?

Now every time a person visits your old domain, they’ll instantly go to your new site.  Keep in mind that when search engines visit your page, they’ll see that it has been redirected and will follow the new one just as they always did for your previous domain name.  Within a few weeks to a few months, the old domain name will gradually be replaced by the new ones as the search engines update their databases.

If you see some initial rankings drop or a drop in traffic, it should all return to normal within a few weeks as your new redirection makes its way through the web.  Make sure any sites linking back to you know your new URL if you’re going to delete your old domain since those links will no longer work if your old domain doesn’t point to the new one.

Try using .htaccess and mod_rewrite the next time you want to change your domain without losing your search engine ranking.  It’s a simple, search engine friendly way to keep all the popularity and reputation you’ve built up!

Sherice Jacob is a web designer, copywriter and author of “Get Niche Quick!” – The Definitive Guide to Marketing Your Business on the Internet.  You can also follow @sherice on Twitter

Sherice Jacob
Sherice Jacob helps site owners improve website performance and increase conversions through her blog and custom design service at iElectrify. You can also follow @sherice... Read Full Bio
Get the latest news from Search Engine Journal!
We value your privacy! See our policy here.
  • I have only had to do this one time and at first it freaked me out because my 1st place Google rankings disappeared for about a month but they did come back exactly where they were before and I was like w00t w00t! :-p

  • I would never thought of this Sherice. Thanks

  • Great step-by-step instructions. Thanks for posting this.

  • Thanks for sharing this. In our company we once had problems with “lighttpd-server”. The mod_rewrite config was quite bad on that one. Would not recomment it for mod_rewriting…
    Best, Tobias

  • .htaccess + godaddy servers = nightmare

  • Great advice, Sherice. This is also a great method for having multiple domains pointing to the same site, I believe.

  • Yes, it also works to point several domains to the same site. I don’t recommend using it on GoDaddy as they tend to make the “simplest” things extraordinarily difficult or time consuming to do (just try creating a database there!). I would choose a host that offers Cpanel instead as there are fewer limitations.

  • Thanks for the tips, its very helpful….

  • lighttpd-server performance %90

  • I’d Like to add that –

    If you wish to change your domain today and want to transfer the trust it earned from Google over the years to the new domain…You can do so easily with a neat feature recently implemented inside Google Webmaster Tools.

    I’m not sure whether SEJ covered it, so I’ll put up my link:

  • Great tips
    Really useful

  • Thanks Sherice, thanks for such a useful information regarding domain name change, it really works..:)

  • Why does every SEO communicate as if Windows servers don’t exists. 🙂 Not hating, just think is funny no one ever talks in iis terms.

  • I’ m not technical enough to understand what you just did, but as an SEO, did it basically do a 301-redirect on a page-by-page basis from the old site to the new site?
    As in if you type in it would do a 301-redirect to

    Paul Zhao

  • @Kevin – Wishful thinking, maybe? *wink* *smile* 🙂

    @Paul – You’re exactly right. I took the cumbersome task of updating the redirects on every page and applied it to the entire domain. Hope this helps!

  • This all sounds good and simple and Google has made it even more simpler through their Webmaster tool now. But the real difficulty is getting all those links from so many external sites point to your new domain. It isn’t easy to contact all those webmasters and convince them to do so…

  • Mod_Rewrite and 301 redirects are great tools for SEO. There are alot of creative things you can do with them.

    Thanks for a good post.

  • Its is very useful for us if we are migrating old to the new domain.

  • Excellent read. Thank you for sharing. Great post

  • thanks a lot..

  • The [I,RP] command is the same of [r=301]?

  • “Once you save the file, upload it to your root directory for your new domain name. ”

    Is this a mistake? I think it should be: upload it to your root directory for your old domain name.

    Am I right?

  • Good catch Dingchao! So sorry for the oversight, you’re absolutely right! I will get that corrected right away.

  • Im about to do this for my website, but my new domain has a brand new site, so the page names will be different from the old site, how can i transfer the old PR from new old inner pages to my new inner pages on the new domain ?

  • Thank you very very much.

  • nice work and comments

  • I’m about to do this. One question though…
    You see, the biggest way I built up my page rank (PR2) was through paying for link submissions to hundreds of directories, and article submission to many blogs. I am a little confused with the part about contacting sites that have links pointing to your old site.

    Wouldn’t any link using the old domain name be redirected to the new domain? If not, I’m afraid that my pagerank will be lost because it’s difficult to contact hundreds of directories with a domain change. – This would make me want to stay with the old domain, which I’m hoping I don’t have to…

    Very easy to follow instructions though, thank you.

  • Hi Kimberley,

    You don’t “have” to contact all of the site owners if you’re switching something like a subdirectory within your own domain – such as being changed to , since the redirect will take people who click to the new page.

    If you’re switching to an entirely new domain though, and you don’t plan on keeping the old one indefinitely to redirect it, then you’d want to let them know – but I’d only worry about the article directories or blogs that actually send you traffic.

  • It would be an entire new domain. I think I understand now, thanks for the info!

  • Thanks for sharing this. In our company we once had problems with “lighttpd-server”. The mod_rewrite config was quite bad on that one. Would not recomment it for mod_rewriting…

  • Also when you did 301 redirect to new site – dont forget to use “Change of address” tool in “Site configuration” section of google webmaster tools. Mat said that it will help Google to redirect rankings faster. As for me it depends of site structure and quantity of indexed pages.

  • Many thanks for the advice. Very useful and understandable for someone like me without much ‘technical knowledge’!

  • Upps i forgat to mention that .htaccess gives 500 error code what can i do help pls

  • Thank you Sherice Jacob.

  • Just stoped by to say tanks 🙂
    I changed my domain today fallowing your tutorial and its all working great!