: Google is indexing main domain despite 301 redirect to subdomain I had applied 'redirect 301' from main domain to subdomain and Google had indexed sumbdomain (and links under it) for years. Now,
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.
More posts by @Debbie626
2 Comments
Sorted by latest first Latest Oldest Best
I found this website to test: htaccess.madewithlove.be/
Then I create a test
.htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^(.*)$ sub.domain.com/ [R=301,L]
Urls tested:
www.domain.com/
output: sub.domain.com/ www.domain.com/something
output: sub.domain.com/something domain.com/
output: sub.domain.com/ domain.com/something
output: sub.domain.com/something
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 ^(.*)$ subdomain.website.com [R=301,L]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.