# Add rel="nofollow" admin setting is not working right, its making parent domain link as nofollow

**URL:** https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226
**Category:** Feature
**Created:** [5월 25, 2015, 6:50오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226 "2015-05-25T18:50:08Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![lovechopra1](https://avatars.discourse-cdn.com/v4/letter/l/4af34b/32.png) [@lovechopra1](https://meta.discourse.org/u/lovechopra1)
#### Post date: [5월 25, 2015, 6:50오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/1 "2015-05-25T18:50:08Z")

</div>

There is a setting in Admin panel:  
**add rel nofollow to user content** : Add rel nofollow to all submitted user content, except for internal links (including parent domains). If you change this, you must rebake all posts with: “rake posts:rebake”

This setting is by default checked but all the links of parent domain is putting up with nofollow attribute.

Please use following steps to replicate:

1 Go to admin panel and search for setting “add rel nofollow to user content”, just to make sure it is checked

 ![](https://global.discourse-cdn.com/meta/original/3X/0/a/0a07a5f1fcd8c6ad1a3f84cb841beeb123a88642.png) 

2 Create a new post and put link of root domain

 ![](https://global.discourse-cdn.com/meta/original/3X/d/5/d56772158dea30a45b3be3fb23dc78d7cfddfd55.png) 

3 Inserted link automatically append with rel=“nofollow” attribute despite of being a parent domain link

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 25, 2015, 8:47오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/2 "2015-05-25T20:47:41Z")

</div>

That does seem like a regression @sam

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5월 25, 2015, 9:07오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/3 "2015-05-25T21:07:23Z")

</div>

not following, how are you changing site setting on [try.discourse.org](http://try.discourse.org)?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 25, 2015, 9:09오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/4 "2015-05-25T21:09:38Z")

</div>

He’s not, the idea that links to

> **[Where Tech Companies Build Communities](https://www.discourse.org)**
>
> The customizable, scalable community platform powering over 22,000 communities. Create knowledge through conversation.

are nofollowed from

> **[Discourse Demo](https://try.discourse.org)**
>
> Demonstration sandbox for Discourse

does not seem in tune with the description of the setting:

> add rel nofollow to all submitted user content, **except for internal links (including parent domains)**

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5월 25, 2015, 9:23오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/5 "2015-05-25T21:23:07Z")

</div>

I think @eviltrout wrote this but my guess is that [www.discourse.org](http://www.discourse.org) is not considered [try.discourse.org](http://try.discourse.org) … only [discourse.org](http://discourse.org) is.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 25, 2015, 9:31오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/6 "2015-05-25T21:31:45Z")

</div>

Yes but I think it should be. Any subdomain of the parent domain should be followed.

Perhaps you can take this @techapj?

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [5월 25, 2015, 9:41오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/7 "2015-05-25T21:41:05Z")

</div>

Looks like `uri.host.ends_with?(site_uri.host)` is the code that does it. It seems that `try.discourse.org` would not match `www.discourse.org`.

Are we sure we’d want it to do that? It might be weird from a security standpoint to make `try` match `www`.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [5월 25, 2015, 10:00오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/8 "2015-05-25T22:00:50Z")

</div>

Speaking for Sitepoint, I could see use out of it with our article integration. Having sitepoint articles followed by default would make a lot of sense and in our case it would be [community.sitepoint.com](http://community.sitepoint.com) matching [www.sitepoint.com](http://www.sitepoint.com)

I would think other article integrated sites would see value in it too.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 25, 2015, 10:18오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/9 "2015-05-25T22:18:11Z")

</div>

It really should work this way.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [5월 26, 2015, 6:48오전 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/10 "2015-05-26T06:48:48Z")

</div>

Fixed via:

[https://github.com/discourse/discourse/pull/3501](https://github.com/discourse/discourse/pull/3501)

Also there was bug when domain like `foo.com` is added in `exclude_rel_nofollow_domains` setting, then domain like `nofoo.com` was also being allowed to be excluded from nofollow. Fixed that too.

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [5월 26, 2015, 7:13오전 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/11 "2015-05-26T07:13:47Z")

</div>

It’s not that simple.

```
uri_domain = uri.host  
uri_domain = "#{uri.host.split('.')[1]}.#{uri.host.split('.')[2]}" if uri.host && uri.host.split('.').size == 3  
uri_domain = "#{uri.host.split('.')[1]}.#{uri.host.split('.')[2]}.#{uri.host.split('.')[3]}" if uri.host && uri.host.split('.').size == 4  

```

This code fails when people use naked ccSLD’s like `example.co.uk` (will follow everything in `co.uk`).

Also `myblog.blogspot.com` will follow everything at `blogspot.com`…

You should use [View the Public Suffix List](https://publicsuffix.org/list/) to resolve this…

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [5월 26, 2015, 7:18오전 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/12 "2015-05-26T07:18:54Z")

</div>

This is about “making links follow” (technically, not making them nofollow), not about making them nofollow.  
Or is that what you mean?

---

<div class="post-metadata">

### Author: ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)
#### Post date: [5월 26, 2015, 7:19오전 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/13 "2015-05-26T07:19:52Z")

</div>

Yes, edited. Thanks.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [5월 26, 2015, 7:47오전 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/14 "2015-05-26T07:47:44Z")

</div>

> [@michaeld](#):
>
> This code fails when people use naked ccSLD’s like [example.co.uk](http://example.co.uk) (will follow everything in [co.uk](http://co.uk)).

Thanks for pointing this out. Will fix.

> [@michaeld](#):
>
> Also [myblog.blogspot.com](http://myblog.blogspot.com) will follow everything at [blogspot.com](http://blogspot.com)…

This is the desired behaviour. If the instance is hosted at `myblog.blogspot.com` then everything at `blogspot.com` **should be** followed.

> [@michaeld](#):
>
> You should use [View the Public Suffix List](https://publicsuffix.org/list/) to resolve this…

Yes I agree, initially I used [publicsuffix-ruby](https://github.com/weppos/publicsuffix-ruby) gem to achieve this, but all tests broke.. 😞 Will try to fix tests.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [5월 26, 2015, 9:37오전 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/15 "2015-05-26T09:37:21Z")

</div>

Updated the PR to use [publicsuffix-ruby](https://github.com/weppos/publicsuffix-ruby) gem. Tests are passing.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [5월 26, 2015, 10:56오전 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/16 "2015-05-26T10:56:59Z")

</div>

I am worried about this kind of stuff, how heavy is this dependency ?

This is a 150k file [https://github.com/weppos/publicsuffix-ruby/blob/master/data/definitions.txt](https://github.com/weppos/publicsuffix-ruby/blob/master/data/definitions.txt) I bet this bloats us with 10k extra strings at least

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 26, 2015, 10:05오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/17 "2015-05-26T22:05:56Z")

</div>

I do not think a whole library should be necessary for this change @techAPJ

Why can’t the test be “ends with correct domain suffix” and then “anything else on front with a period between”?

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [5월 26, 2015, 11:52오후 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/18 "2015-05-26T23:52:52Z")

</div>

It’s because the requirements are like this:

- Discourse at `forum.example.com`:
- `example.com/` - followed
- `www.example.com/` - followed
- `blog.example.com/` - followed
- `www.2example.com/` - nofollow
- Discourse at `forum.co.uk`:
- `co.uk/` - nofollow
- `example.co.uk/` - nofollow
- Discourse at `awesome.website`:
- `website./` - nofollow
- `example.website/` - nofollow

You can’t tell those apart with the number of dots.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [5월 27, 2015, 12:08오전 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/19 "2015-05-27T00:08:14Z")

</div>

Number of dots should not be used.

Known domain name suffix of site should be used, e.g.

`example.com`  
`example.co.uk`  
`example.website`

With the rule being “any domain name with a dot plus this suffix is followed”

**If necessary add another site setting to hold this value.** If the value is not present, the nofollow will simply not be as accurate, e.g. it will nofollow stuff that it technically should not. It errs on the side of caution.

That’s much preferable to a giant library dependency…

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [5월 27, 2015, 12:13오전 UTC](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226/20 "2015-05-27T00:13:48Z")

</div>

Worst case, default to the discourse domain, that way, once added, it only no-follows internal links; ie: [community.sitepoint.com](http://community.sitepoint.com), and we’d have to make it more generic by changing it to [sitepoint.com](http://sitepoint.com)

However, it needs to be able to not match

[example.com/sitepoint.com/mypage.php](http://example.com/sitepoint.com/mypage.php) or similar related URL renderings.

[Next page](https://meta.discourse.org/t/add-rel-nofollow-admin-setting-is-not-working-right-its-making-parent-domain-link-as-nofollow/29226.md?page=2)
