Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I had applied 'redirect 301' from main domain to subdomain and Google had indexed sumbdomain (and links under it) for years. Now, for some reason Google has started indexing the main domain while keeping all of subdomain links indexed except one - subdomain.maindomain.com (this one has been de-indexed and replaced by maindomain.com). Main domain shouldn't even be listed in Google results and subdomain.maindomain.com should remain there. There are about 12 results like maindomain.com/folder listed in Google results as of now, I'd like them removed but without using robots (read somewhere it's bad for SEO if combined with 301 redirect?) or requesting removal in Google Webmasters Tools (I'm worried Google will de-index whole site).

Following is the .htaccess config for reference:

RewriteEngine on


AddHandler application/x-httpd-php54s .php

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

There's no robots file as of now.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

It looks like you are only redirecting the home page. Your rewrite rule states that for the redirect to work, the path of the URL may only contain an optional slash.

So, if Googlebot somehow gets links deeper into the site, it would be able to crawl the site except for the home page.

You should change your rewrite rule to the following:

RewriteRule ^(.*)$ http://subdomain.website.com$1 [R=301,L]
share|improve this answer
    
Thanks, but it doesn't seem redirecting to sumbdomain? –  Nix Jul 11 '13 at 19:13
    
Right, I had a bug. I edited it to corrected the rule. –  Stephen Ostermiller Jul 11 '13 at 19:15
    
Thanks, I'll try this one :) –  Nix Jul 11 '13 at 19:17

I found this website to test: http://htaccess.madewithlove.be/

Then I create a test

.htaccess

RewriteEngine on

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

Urls tested:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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