Redirect site to new domain and keep Google Verification on old one

Posted on by |

Quick but very useful tip if you are moving your website to new domain. The problem is that if you rewrite whole site using .htaccess file your Google Verification is also gone, because your verification file or meta tag will no longer be available.

The solution is this simple snippet to be inserted in your old site’s .htaccess file – use it in conjunction with html file upload verification method.

The snippet redirects all URLs from the od site to new one while keeping access to your Google Verification file on the old one.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/yourgoogleverificationfilename\.html
RewriteRule ^(.*)$ http://www.yournewdomain.com/$1 [R=301,L]

Please note \.html – the dot character has to be escaped by backslash \, it is not a part of filename.

Having done this you need to do another very important step – log into your Google Webmaster’s Tools and request change of address. Just click on the website you want to change the address for, then click gear icon and change address (see image below) This way you will let Google know that you are actually changing the address for the whole site.

change-of-address