Search Console - Change of Address. 301 htaccess example

Moving to a new domain can smash your Google ranking - unless you tell Google about it. If you are a user of Google's Search Console aka Webmaster Tools you have the option to use the "Change of Address" page which can be found in the settings.

Screen Shot 2015-08-31 at 23.54.00

I personally want to change the domain for this blog from my old happy-coding.org to a the subdomain journal.happy-coding.com. So I called the "Change of Address" in my happy-coding.org property.


Google shows 3 steps you need to fulfil until you can submit your domain change request. The items 2 and 3 are somehow conflictive. On the one hand they want you to redirect all pages with an 301 code. On the other hand they want you to keep the verification alive - of both pages.
The latter was in my case a HTML file on my original .org domain. So what to do?

The solution is to avoid the redirect of exactly one file on the old domain - this file is the verification file. So the redirect commands in my .htaccess file looks like this:

RewriteCond %{REQUEST_URI} !=/google74c35edd5172fdb2.html RewriteCond %{HTTP_HOST} ^(www\.)?happy-coding\.org$ RewriteRule (.*) http://journal.happy-coding.com/$1 [R=301,L]

Now everything is redirected to the subdomain except the file Google needs for verification. After that all the three steps passed and I was able to submit the request.