homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Rules Affecting Google Indexing of pages

 5:52 pm on Nov 21, 2010 (gmt 0)

Hi I have the following rules on my htaccess file:

#################BEGIN RULES ON LIVE SITE
# Externally redirect direct client requests for subdomain-subdirectory URLs which
# resolve to existing subdirectories back to canonical subdomain root URLs
RewriteCond $1 !^(features|terms-of-service|about-us|funeralnotice|onlinememorials|signup|media|includes|modules|cgi-bin|templates|xmlrpc|language|libraries|plugins|administrator|component|images)
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([a-z0-9\-]+)/[^\ ]*\ HTTP/
RewriteCond %{DOCUMENT_ROOT}/$1 -d
RewriteRule ^([a-z0-9\-]+)/(.*)$ http://$1.mysite.com/$2 [R=301,L]
# Externally redirect requests for /features, /about-us, /signup, /images in subdomains to main domain
RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+)\.mysite\.com
RewriteCond %1 !^www\.
RewriteRule ^(features|about-us|funeralnotice|onlinememorials|terms-of-service|signup|component|includes|media|cgi-bin|templates|xmlrpc|language|modules|libraries|plugins|administrator|images(/.*))$ http://mysite.com/$1 [R=301,L]
# Externally redirect all www hostnames to non-www hostnames
RewriteCond %{HTTP_HOST} ^(([a-z0-9\-]+\.)*)www\.(([a-z0-9\-]+\.)*)mysite\.com
RewriteRule ^(.*)$ http://%1%3mysite.com/$1 [R=301,L]
# Internally rewrite requests for <subdomain>.example.com URLs to the
# /<subdomain>/ directory filepath, unless this has already been done
#RewriteCond $1 !^(features|about-us|funeralnotice|onlinememorials|terms-of-service|signup|media|includes|modules|cgi-bin|templates|xmlrpc|language|libraries|administrator|plugins|component|images)
#RewriteCond %{REDIRECT_STATUS} =""
#RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+)\.mysite\.com
#RewriteCond %1 !^www\.
#RewriteRule ^(.*)$ /%1/$1 [L]
######################END RULES

On my homepage I have links to my subdomains however they are getting indexed in google as subdomain1.subdomain2.mysite.com.

How can i stop this

[edited by: jdMorgan at 3:22 am (utc) on Dec 2, 2010]
[edit reason] Formatting clean-up for readability [/edit]



 9:20 pm on Nov 22, 2010 (gmt 0)

Can any one assist?


 6:27 pm on Nov 29, 2010 (gmt 0)



 2:58 am on Dec 2, 2010 (gmt 0)

The code isn't readable due to the auto-linking of URLs not enclosed in [ code ] sections, so I'll have to go edit it...

Also, we don't know your site, so if it is getting indexed as subdomain1.subdomain2.mysite.com, then how do you think that is happening, and what *should* it have been indexed as?



 4:59 am on Dec 6, 2010 (gmt 0)

its just supposed to be indexed as subdomain1.mysite.com and not multiple subdomains of subdomains.


 3:08 am on Dec 7, 2010 (gmt 0)

OK. I have looked at this code for several days in a row now, and I don't see anything wrong with it. So, two more questions:
1) Do you have any additional rewriterules in this or in any other .htaccess files that may be interfering?
2) Do you use a "control panel" to configure the subdirectories which are used to store files for each subdomain?

In case 1, any rules that invoke a redirect after you have already done an internal rewrite can cause problems. In case 2, the control panel may be "writing code" in the server config file that does an internal rewrite, and if you then do an external redirect, then that can cause problems.

Basically, in any case, you never want to allow any external redirect to be invoked after any internal rewrite has been invoked.

One thing you might try is to the use the "Live HTTP Headers" add-on for Firefox and Mozilla-based browsers (or a similar add-on) to "watch" the HTTP client requests and server responses. If you see unexpected redirect results --and especially multiple redirects per user request-- then that might give you a useful clue about the problem.



 5:41 am on Dec 24, 2010 (gmt 0)

thanks jdMorgan, i found out that the way i coded a module was rendering the subdomains, however i was getting more than just subdomain1.subdomain2.subdomain3.mysite.com indexed by google and have had to go thorugh webmaster tools to remove them. would this hurt my rankings?


 3:46 pm on Jan 5, 2011 (gmt 0)

Yes, it will hurt your rankings temporarily until Google re-indexes your site. To speed up the process, your should consider adding rules to explicitly redirect all those bad indexed URLs to the correct ones, and leave those rules in place for a year or so, until Google 'forgets' that those bad URLs existed.



 8:06 pm on Jan 14, 2011 (gmt 0)

okay, i cant seem to be able to create those rules.

how would i go about redirecting multiple index subdomains to just the first subdomain?


 5:18 pm on Jan 15, 2011 (gmt 0)

anyone assist


 4:56 pm on Jan 16, 2011 (gmt 0)

We don't know what is a correct subdomain on your site, and what is an incorrect subdomain... So we can't help unless you very-thoroughly define these "bad subdomain requests" for us and describe exactly how they should be "repaired" to make them into "good subdomain requests."

Only *you* really know in detail what you want the code to do on your server. And more importantly, what you want the code to *not* do... :)



 2:17 am on Jan 17, 2011 (gmt 0)

okay basically i want this type of redirect:

anysubdomain1.anysubdomain2.anysubdomain3.mydomain.com to redirect to just anysubdomain1.mydomain.com or if there is anysubdomain1.anysbdomain2.mydomain to redirect to anysubdomain1.mydomain.com ie only one subdomain and the first one too. once there is more than one subdomain redirect to the first one only.


 9:47 pm on Jan 19, 2011 (gmt 0)

# Externally redirect all multiple-subdomain hostnames to first-subdomain hostnames
RewriteCond %{HTTP_HOST} ^([a-z0-9\-]+\.)([a-z0-9\-]+\.)+mysite\.com
RewriteRule ^(.*)$ http://%1mysite.com/$1 [R=301,L]



 9:36 pm on Feb 11, 2011 (gmt 0)

Thanks jdMorgan,

I have managed to get most of these link sorted out. However i still have a couple more showing up in googles index that i want to sort out.

Along with the rewrite rules at the top how can i

re-write a subdomain that is being indexed as

mysubdomain.example.com/?mv=0 to be



mysubdomain.example.com/?mv=1 to be


so that when i request mysubdomain.example.com/information it is the same as if im doing mysubdomain.example.com/?mv=1


 5:24 am on Feb 15, 2011 (gmt 0)

can anyone assit


 10:53 pm on Feb 17, 2011 (gmt 0)

Please be patient. Due to other responsibilities, I for example am only able to check this forum for a few minutes per day... This is yet another reason to try to code solutions yourself, and post specific questions about specific problems instead of waiting around for an answer to a very-general questions.

Specific questions are often much easier to answer than general ones, and will get answered faster because of that.

First URL:

RewriteCond %{HTTP_HOST} ^mysubdomain\.example\.com
RewriteCond %{QUERY_STRING} ^mv=0$
RewriteRule ^$ http://mysubdomain.com/biography? [R=301,L]

Now you can do the second one... :)



 3:16 am on Feb 18, 2011 (gmt 0)

okay JIM, but at first glance it seems that u are using mysubdomain which should be anysubdomain, a wildcard for any subdomain, and the third line says [mysubdomain.com...]

I want that to be like so eg domain1.example.com/biography

domain2.example.com/biography and so on


 5:09 am on Feb 18, 2011 (gmt 0)

Well that is not obvious from your specification/example above... We need the details --all of them-- before we start coding. Taking the time to provide a correct and comprehensive requirements specification with good examples will save a lot of time... for everyone.

RewriteCond %{QUERY_STRING} ^mv=0$
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule ^$ http://%1.example.com/biography? [R=301,L]

That will accept any subdomain of example.com and pass it to the output. It does require a subdomain, though. If you also want to redirect requests for the TLD "example.com", then you could use

RewriteCond %{QUERY_STRING} ^mv=0$
RewriteCond %{HTTP_HOST} ^([^.]+\.)?example\.com
RewriteRule ^$ http://%1example.com/biography? [R=301,L]

There are dozens of technically-correct solutions, but likely only one is correct for your site's actual requirements.



 7:10 pm on Feb 19, 2011 (gmt 0)

Hmm guys.. this is not working. I do anysubdomain.example.com/biography and it doesn't work, doesnt seem to be passing the ?mv=0 to get the correct page.

Basically i want all anysubdomain.example.com/biography to be the same as anysubdomain.example.com/?mv=0

for seo purposes.


 8:33 pm on Feb 19, 2011 (gmt 0)

Which one of those is a "URL used out on the web" and which one is "the path and file used inside the server"?

If those are both "URLs used out on the web", which one do you want users to use to access the content?


 1:10 am on Feb 20, 2011 (gmt 0)

URL used out on the web is: anysubdomain.example.com/biography and the path and file used inside the server is:



 1:21 am on Feb 20, 2011 (gmt 0)

URL used out on the web is:

and the path and file used inside the server is: /index.php?mv=0

Inside the server, there is notion of domain names. Only paths and files exist.


 4:35 am on Feb 20, 2011 (gmt 0)

okay, the server path is just ?mv=0


 9:59 pm on Feb 23, 2011 (gmt 0)

sorry g1smd yes you are correct. i doesnt seem to be passing the mv=0 which php code is expecting. thought a rewrite would make it work


 10:17 pm on Feb 23, 2011 (gmt 0)

So what i need is : anysubdomain.example.com/biography to act as



 5:07 am on Mar 2, 2011 (gmt 0)

Guys, I look more closely at I wanted to achieve and i notices that the url that i need to rewrite is like this :

This is what id type in the browser:


and it should be like doing this:


Where fnamelname is anysubdomain which as to go with the rules that i already have at the begining when i started this thread


 5:55 am on Mar 2, 2011 (gmt 0)

Maybe you have no permission to post link <a href="http://www.google.com.">yet</a>.


 5:55 am on Mar 2, 2011 (gmt 0)

Maybe you have no permission to post link yet [google.com] .


 6:08 am on Mar 2, 2011 (gmt 0)

whats this


 1:49 am on Mar 3, 2011 (gmt 0)

Can anyone continue to assist?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved