Getting 301 redirect error in Google Webmaster Tools while using "change address"

Getting 301 redirect error in Google Webmaster Tools while using "change address" - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about google-search-console, htaccess, 301-redirect, , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


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


Solution :

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]


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.



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!


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect