5

So I'm moving my website from one domain to another. In this process I'm using the "change address" function in Google Webmaster Tools on my old-domain.com, "switching" it to / choosing my verified new-domain.com.

In Step 2 of this process, Google Webmaster Tools will check whether 301 redirect is setup properly on old-domain.com... And it fails...

Translated to English it says: "Could not find any 301-redirect directives".

I've setup the 301 redirect on my old-domain.com in the .htaccess - and no other content is in the file than this:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^old-domain.com$ [NC]
RewriteRule ^(.*)$ http://new-domain.dom/$1 [R=301,L]

Am I missing something?

Note that the redirecting works perfectly

  • Is old-domain.com a completely separate hosting account? Are you using a www subdomain? FollowSymLinks must also be enabled for mod_rewrite to function, if it's not already. – MrWhite Mar 6 '15 at 10:58
  • Yup, old-domain.com is on a completely different hosting account and im not using any subdomains. I havent defined any FollowSymLinks in my .htaccess - is it important? Redirect of urls are working fine – user1231561 Mar 6 '15 at 11:28
  • Ah, if redirecting is working OK (sorry, missed that) but Google is reporting an error then are you sure that Google is not requesting www.old-domain.com (ie. with the subdomain)? – MrWhite Mar 6 '15 at 11:33
  • Yup - since there are no subdomains, that would not be possible :). The domain is within webmaster tools defined as: old-domain.com – user1231561 Mar 6 '15 at 12:03
  • I even followed the suggestion of .htaccess here: joomlaseo.com/Blog/changing-domain-url-using-301-redirect - where he afterwards does the exact same thing changing address. Still the same error with my account :( – user1231561 Mar 6 '15 at 14:24
3

Your .htaccess actually looks OK, and you say the redirection is working OK for you. The only possibility is that if Google is requesting the www subdomain? In this case, Google would not see the redirect since you are specifically checking for the bare domain.

Since your old-domain is a separate hosting account then your directives can be simplified (ie. no need to check the requested HOST, since it can only be old-domain anyway), and this will also capture the www subdomain (if that is indeed the problem)...

All that's required is:

RewriteRule (.*) http://new-domain.dom/$1 [R=301,L]
  • In Webmaster tools, I can see under "settings for old-domain.com" that it is defined as "show website as my-domain.com" = not with "www". I'll try your suggested approach and see if that helps :) – user1231561 Mar 6 '15 at 12:07
  • And the validated domain in GWT is old-domain.com, not www.old-domain.com? If so then there should be no reason why Google can't see this redirect. – MrWhite Mar 6 '15 at 12:10
  • Everywhere in GWA it's listing with old-domain.com. The account added also just shows with old-domain.com and as a test I just added the account with www.old-domain.com (which you need to do the first time when changing the setting to "show website as my-domain.com"). Removed the "www." account again - but no luck yet. Indeed very weird. I'll keep on the fight – user1231561 Mar 6 '15 at 12:24
  • Just a thought, is the new-domain validated in GWT, and what validation method are you using? – MrWhite Mar 6 '15 at 12:37
  • Yup, new domain validated and confimed by .html file :) – user1231561 Mar 6 '15 at 13:06
1

Make sure when you are adding a domain in Google Webmaster Tools, use the domain as www.example.com instead of example.com. This will also cause 301 error when you revamp or migrate the site.

If you have already added example.com then also add this too www.example.com and verify it in webmaster tools.

  • I'm not sure what you mean by "This will also cause 301 error". Adding properties to GWT never causes your site to 301 redirect, and redirects are not "errors" – Stephen Ostermiller Dec 17 '16 at 10:19
  • I mean just use www.example.com instead of example.com while adding the property in google webmaster tools – OmkieIT Solutions Dec 17 '16 at 12:30
0

Your htaccess is fine and mabye working, but the correct way is this:

RewriteCond %{HTTP_HOST} ^old-domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old-domain\.com$
RewriteRule ^(.*)$ "http\:\/\/www\.new-domain\.com\/$1" [R=301,L]

Because google will chek both www and non www protocols.

Once you make this change, please chek it if works fine with this tool: http://web-sniffer.net/

After you validate the step 2, I warn you, step 3 may fail depending on the validation method you had for webmasters tools. To resolve this, you will have to re-validate your old domain by using a configuration option in your DNS (acseso to your service ISP provider's option). Webmasters tools will give you a code when you choose that option, and will ask you to create a TXT record in your DNS settings.

Good luck!

  • Hi Thorma - thanks for contributing - appreciate it! I will need to keep the same url structure from old-domain.com - right now with the above - it seems everything will just redirect to new-domain.com - like: old-domain.com/subdir/ should redirect to new-domain.com/subdir/ etc., but doesn't seem to do so with the above? – user1231561 Mar 6 '15 at 12:30
  • Bit of an aside, but... there is no need to escape slashes or dots in the RewriteRule substitution (or surround it in quotes) since it is an ordinary string, not a regex. – MrWhite Mar 6 '15 at 12:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.