Welcome to WebmasterWorld Guest from 54.90.204.233

Forum Moderators: Ocean10000 & phranque

How to noindex hosting domain subfolder but not my domain

     
7:16 pm on Feb 4, 2019 (gmt 0)

New User

Top Contributors Of The Month

joined:Feb 4, 2019
posts: 15
votes: 1


I don't know why, but google has in a few cases picked up one of our websites "www.websitewehost.com" and our internal structure on our hosting "www.ourhostingdomain.com/websitewehost" in the index. Our host will allow us to use either or both once we go live - they both point to the same folder on our server. However we only want "www.websitewehost.com" to be indexed, not "www.ourhostingdomain.com/websitewehost". I can't put a robots file with "Disallow /" in the "www.ourhostingdomain.com/websitewehost" root folder, because it will also be seen when visiting "www.websitewehost.com" and prevent indexing of the whole site (which we want). But as it stands now, google could see this as duplicate content. How can I prevent indexing of "www.ourhostingdomain.com/websitewehost" but allow "www.websitewehost.com" since they contain the same set of files?
4:59 pm on Feb 6, 2019 (gmt 0)

New User

Top Contributors Of The Month

joined:Feb 4, 2019
posts: 15
votes: 1


This is not something I have control over.

Our hosting domain is ourhostingdomain.com.

When I add a second/third/fourtieth domain on our hosting plan as an add-on domain, they are physically placed on the disk in
"www.ourhostingdomain.com/public_html/addondomain1"
"www.ourhostingdomain.com/public_html/addondomain2"
"www.ourhostingdomain.com/public_html/addondomain2"

The host sets it up so it can be reached via:
"www.ourhostingdomain.com/addondomain1"
"www.ourhostingdomain.com/addondomain2"
"www.ourhostingdomain.com/addondomain3"

or via
"www.addondomain1.com"
"www.addondomain2.com"
"www.addondomain3.com"

The first should never be indexed (or used for anything, really, but it exists).
The latter is how the site is accessed, like any other site.

"www.ourhostingdomain.com/addondomain1" and "www.addondomain1.com" both point to the same folder on the server, "www.ourhostingdomain.com/public_html/addondomain1".

My goal is to have visits by indexing bots and people to "www.ourhostingdomain.com/addondomain1" be 301 redirected to "www.addondomain1.com" without messing up indexing bots or visitors to "www.addondomain1.com".

Are you suggesting this will do the job in .htaccess?:

RewriteCond %{HTTP_HOST} !(ourhostingdomain.com/addondomain1)
RewriteCond %{HTTP_HOST} !^addondomain1.com$ [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://www.addondomain1.com/$1 [R=301,L]
6:07 pm on Feb 6, 2019 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15507
votes: 752


First things first: Yikes. Last night my fingers parted company from my brain, and I was hoping to get the post corrected before you saw it, but no luck. The first few paragraphs should read:
Each of your addon domains should have a domain-name-canonicalization redirect. phranque gave the standard form a few posts back:
RewriteCond %{HTTP_HOST} !^example\.addon$ [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://example.addon/$1 [R=301,L]
(This is the form for an https site. If it is http, remove the OR flag and the second Condition.)

This means: If the requested host is anything other than "example.addon" (give your exact preferred form, whether it is with or without www), and/or if the request is not https, then redirect the request to https://example.addon.

Now then:
This is not something I have control over.
Yes, we understand how the primary/addon directory structure works. Looks like I was not the only person experiencing brain farts last night ;) so don't sweat it.

:: pause for extreme happiness that my host uses the “userspace” directory structure instead, which I didn’t fully appreciate until I added a second domain ::

Are you suggesting this will do the job in .htaccess?:
RewriteCond %{HTTP_HOST} !(ourhostingdomain.com/addondomain1)
No. “ourhostingdomain.com/addondomain1” is not a hostname. It looks as if you have mixed up two different rules: one that is only for the primary domain--which has to be located in the master htaccess--and one for the addons.

Each of the addons needs its own canonicalization redirect, in the form given at the top of the present post, and that redirect has to be physically located in the htaccess for that addon's directory. This is why it has been so important to verify that each of those addons has its own separate htaccess.

Before continuing, go back and reread the post that talks about htaccess and physical directories.

Now, here is what all the mysterious squiggles mean:
! at the beginning of anything means “NOT” whatever-comes-after. In the case of a canonicalization redirect, it is expressed as a negative because you’re saying “anything other than the one and only exact form which is the only form I want to see”.
^ is an opening anchor: “the string I’m testing has to begin like this”
$ is a closing anchor: “has to end like this”. The Condition for a canonicalization redirect needs both anchors, because you're matching an exact form, nothing more and nothing less, for example “example.addon” is right but “www.example.addon:8080” is wrong.
(blahblah)? means that the part inside parentheses is optional
(onething|otherthing) means that the part inside parentheses can be either “onething” or “otherthing”
10:08 pm on Feb 7, 2019 (gmt 0)

New User

Top Contributors Of The Month

joined:Feb 4, 2019
posts: 15
votes: 1


Someone elsewhere has suggested this would work and it seems super simple:

RewriteRule ^/addondomain1(.*) http://www.addondomain1.com$1 [R=301,L]


Do you think that would cover....

http://www.ourhostingdomain.com/addondomain1/index.html
and
http://www.ourhostingdomain.com/addondomain1/subfolder1/page3.html


and change it to:

RewriteRule ^/addondomain1(.*) https://www.addondomain1.com$1 [R=301,L]


...if it is one of our sites using ssl?
10:45 pm on Feb 7, 2019 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11613
votes: 195


RewriteRule ^/addondomain1(.*) https://www.addondomain1.com$1 [R=301,L]

remember this?
The directory path where the rule is defined is stripped from the currently mapped filesystem path before comparison (up to and including a trailing slash). The net result of this per-directory prefix stripping is that rules in this context only match against the portion of the currently mapped filesystem path "below" where the rule is defined.

the leading slash definitely won't match.
whether or not the additional path information is stripped/will match depends.

why not just give it a try - with and without the directory name - and see which one works?
This 34 message thread spans 2 pages: 34