Here is my question, Recently I moved my site from blog.mysite.com to www.mysite.com.

Then I added 301 permanent redirection using this code in .htaccess file.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog\.mysite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.blog\.mysite\.com$
RewriteRule ^/?$ "http\:\/\/www\.mysite\.com\/" [R=301,L]

Everything was OK, and when I go to my site by typing blog.mysite.com it automatically redirected to www.mysite.com.

But, I found that when I click a Google search result of my old site doesn't redirect to the new site.

Guess Google result URL is


Though it doesn't redirect to


It only goes to the old URL which is


which shows my hosting provider's 404 Error page.

So, then what I did was creating a custom 404 error page and added a php code to get the Google's search result URL and replace the word 'blog' with 'www' then redirecting to


So, now everything's working perfectly and no any error pages.

But I want to know if what I've done is OK with SEO logics. I've heard that 301 permanent redirection tells the Search engines that the site has moved. And where the new site is.

I want to know if there's no damage to 301 redirection after I've created custom 404 page and added a tricky redirection...

Thanks... Hope you understand. :-)


2 Answers 2


Google SEO logic is always a tightly held secret, but moving your domain can/will always result in a lower site ranking. By having the auto forward setup the way you did you might be effectively giving Google two sites (so far as it knows) to keep page rankings for, and as a result your ranking will always be lower if it is being divided among two or more domains.

This is always the result when you move a domain anyway. As a service to your viewers it is your responsibility to make your best effort to keep any bookmarks they may have had valid for as long as possible... which you have done.

I have the suspicion that Google will tell you that what you are doing is correct as it is in your viewers best interest to keep your site functioning in the manner that they are accustom to. However you may be in the gray area between providing good service and using the best SEO.

Living in the gray area between good service and good SEO is not a bad place to be if you think of it as the best of both worlds. Google is pretty smart, and it is only a matter of time for any loss you had to be corrected so long as your site is still servicing your viewers and they are still coming to your site, no matter how they are getting their.

Another option that might be available to you through your host is to autoforward blog.yoursite.com to www.yoursite.com as a wildcard forward. This will have the same forwarding effect you already have, and it should/may also give Google bots some feedback as well.

  • I do what I can.
    – KnightHawk
    Sep 12, 2014 at 16:50

The only thing that matter is what clients (including Googlebot) see. When you implement 301 redirects, it doesn't matter if you do it using Apache's mod_alias, rewrite rules, or through a custom 404 handler. The only thing that matters is the status code that browsers and bots see when they visit the URL. You should test this yourself using the command line program curl. It should look something like this:

$ curl --head http://blog.example.com/some-page.html
HTTP/1.1 301 Moved Permanently
Server: Apache
Content-Type: text/html; charset=UTF-8
Date: Sat, 20 Sep 2014 23:44:25 GMT
Location: http://example.com/some-page.html
Transfer-Encoding: chunked
Connection: Keep-Alive

Just because you have used your custom 404 handler to produce a 301 redirect, it doesn't mean that clients ever see a 404 error. In fact they don't. Custom 404 handlers can return any status, not just 404. You have made it so the hander returns 301 status in these cases.

There will be no way for Google to know about your convoluted setup. Because of that, your implementation is absolutely fine from an SEO standpoint.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.