# Handle external urls in topic body for subfolder installation

**URL:** https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330
**Category:** Support
**Created:** [December 4, 2017, 9:40am UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330 "2017-12-04T09:40:56Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [December 4, 2017, 9:40am UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/1 "2017-12-04T09:40:57Z")

</div>

Hi, we have a forum installed in subfolder, `https://www.cuba-platform.com/discuss` . The main website has a store located at `https://www.cuba-platform.com/store` . I would like to share this link in some topic or post of our forum. But Discourse handles this URL as internal, it adds **/discuss** to the URL: `https://www.cuba-platform.com/discuss/store` when I click the link in composed message.

The workaround I found - to use a link without **www**. But I would like to have a permanent solution, because users may publish any external links pointed to our website/old forum and those links will be always dead, and users do not know about the workaround.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 4, 2017, 7:01pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/2 "2017-12-04T19:01:47Z")

</div>

Your solution is a pretty good one. Your only other option, I believe, is a custom plugin that adds a route for that address and redirects to the external (to Discourse) server.

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [December 4, 2017, 7:54pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/3 "2017-12-04T19:54:31Z")

</div>

You can do this by defining permalinks in admin. In my example, my subfolder is `/forum`:

 ![Admin_-_Neil_Tests_The_Things](https://global.discourse-cdn.com/meta/original/3X/d/e/de2038092d90cc49e2c84a1158bcc8d8ec572ef8.png)

I’m not sure if both are necessary, but I created them to be sure.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 4, 2017, 11:20pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/4 "2017-12-04T23:20:43Z")

</div>

Of course! I thought that I’d remembered that permalinks didn’t work this way, but maybe it was that permalink normalizations work only for permalinks.

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [December 5, 2017, 7:48am UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/5 "2017-12-05T07:48:59Z")

</div>

Thank you, guys, but I assume this is a bug. The forum _installed in a subfolder_ should not change any urls typed manually. I hope this information will help to detect a problem and fix it.

Here it is an example:

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/c/bc8321f543f597f5ea726dd2277c2ba032351ea0.png)

You may see, that the link points to the path **out of the forum** , let’s say ‘external url’ (for mind, my forum is located at `https://www.cuba-platform.com/discuss`).

The poster expects that anybody can follow the link later, as he(she) see on the screen - `https://www.cuba-platform.com/store`.

But actually forum redirects to another address `https://www.cuba-platform.com/discuss/store` which does not exist. This is because the forum has been installed in subfolder `/discuss`. I am sure that forum settings are correct 😉. For that reason nobody knows how many cases with external links exist, and how many permanent rules should be predefined in the forum settings. The same problem is to have a plugin/php-script to handle such links.

As I remember, almost all external links posted by users were redirected to inexistent forum addresses, though those links were not located in forum. Users even cannot share a link to download page `https://www.cuba-platform.com/download`

I already have reported the same [subfolder issues](https://meta.discourse.org/t/admin-link-in-subfolder-mode-is-incorrect/72920/11). Let me post it again, because here is a right place for them, I think. I filled some settings fields with custom values (terms of use, privacy policy etc) and tried to access them:

1. Go to `https://www.cuba-platform.com/discuss/guidelines`
2. Left click `https://www.cuba-platform.com/terms-of-use` - redirects to wrong location.
3. Go back to guidelines.
4. Left click `https://www.cuba-platform.com/privacy-policy` - redirects to wrong location.
5. Return to guidelines.
6. Left click `https://www.cuba-platform.com/faq` - redirects to correct location.
7. Open browser console and click Back button (go back). It will show unstoppable redirect.

 ![image](https://global.discourse-cdn.com/meta/original/3X/4/5/454c4d66f2331f47358124733147b6334e246df2.png)

P.S. Currently I found that if I **middle click** the link (aka open the link in the new tab, Firefox) it opens the correct url! 🙂

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 5, 2017, 1:27pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/6 "2017-12-05T13:27:15Z")

</div>

> [@Ivan\_Rapekas](#):
>
> Thank you, guys, but I assume this is a bug

You can call it that. The permalink solution is the solution to your problem.

---

<div class="post-metadata">

### Author: ![tpavliuk](https://avatars.discourse-cdn.com/v4/letter/t/d6d6ee/32.png) [@tpavliuk](https://meta.discourse.org/u/tpavliuk)
#### Post date: [December 27, 2017, 2:34pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/7 "2017-12-27T14:34:45Z")

</div>

Hi, guys!

We have forum installed in subfolder: [https://i.materialise.com/forum/](https://i.materialise.com/forum/)  
It seems I have similar problem with external links. When user clicks on external link, he gets redirect to our domain with path and query string from original url.  
For example:  
`https://i.materialise.com/watch?v=<video_id>`  
instead of  
`https://youtube.com/watch?v=<video_id>`

Open in new tab menu and middle button click works well.

Please advise, how to solve this.

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [January 10, 2018, 1:55pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/8 "2018-01-10T13:55:40Z")

</div>

Unfortunately it does not work for me.  
I waited for 1.9.0 release to perform tests on stable version. I added both lines without no success.

 ![изображение](https://global.discourse-cdn.com/meta/original/3X/7/a/7a5db4a5770350f5916d378719a7383ed9ef04d1.png)

Here it is a list of static links from main page of our website, all of them broken.

 ![изображение](https://global.discourse-cdn.com/meta/original/3X/1/2/12d4ce2eb9b026a5413ef1382fe7ce52d4636ea3.png)

When the user posts similar links in our forum, those links become dead.

Could anybody reproduce this bug?

p.s. I found weird google stats, some URLs return different codes:

1. _200_ for anonyms;
2. redirect _301_ to privacy-policy page for logged users;
3. _403_ for Google bot  
example urls:  
[https://www.cuba-platform.com/discuss/t/6-3-0-rc2-group-hierachie-import-error](https://www.cuba-platform.com/discuss/t/6-3-0-rc2-group-hierachie-import-error)  
[https://www.cuba-platform.com/discuss/t/6-4-webinar](https://www.cuba-platform.com/discuss/t/6-4-webinar)

---

<div class="post-metadata">

### Author: ![neil](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neil/32/102150_2.png) [@neil](https://meta.discourse.org/u/neil)
#### Post date: [January 10, 2018, 4:07pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/9 "2018-01-10T16:07:37Z")

</div>

I have a live demo of it working for me [here](http://gtmdiscourse.neillalonde.com/forum/t/it-seems-to-be-working/14/7?u=neil) using the [above example](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/3).

 ![11 AM](https://global.discourse-cdn.com/meta/original/3X/3/8/38b47e1f2c74fcf3e4cfb49a937a29c2cb4948b0.png)

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [January 11, 2018, 8:49am UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/10 "2018-01-11T08:49:40Z")

</div>

I am sorry, that was my fault. I used `www` in permalinks earlier. It works without `www` now. Probably the problem with `www` is on my side, I will investigate it later. Thanks!

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [January 11, 2018, 12:48pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/11 "2018-01-11T12:48:22Z")

</div>

@neil, I have created a topic, where you may check the broken url, it will show 404:

> **[Broken external link](https://forum.cuba-platform.com/t/broken-external-link/3376)**
>
> Hi, currently this URL does not work:

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [May 24, 2018, 8:36am UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/12 "2018-05-24T08:36:34Z")

</div>

Hello,

this is still a bug, yesterday checked on [v2.0.0.beta10 +117](https://github.com/discourse/discourse/compare/d2efd338e6620964d2d7224ffc47f23e817c670a...tests-passed). No chance to fix it by permalinks. It is really painful, because for each posted link I need to create a permalink.

For example, i can create a permalink for `https://www.cuba-platform.com/development`, but I have to do the same for:  
`https://www.cuba-platform.com/development/bla`  
`https://www.cuba-platform.com/development/bla-bla`  
`https://www.cuba-platform.com/development/bla-bla-bla`

Moreover, first time the link is always broken until someone reports that it is broken 😣. I even tried to use Saved searches to catch possible broken URLs, this made me a happy zombie-watcher 🧟.

Please fix it for subfolder installation…

---

<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: [May 24, 2018, 9:19am UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/13 "2018-05-24T09:19:57Z")

</div>

You should rethink your commitment to subfolder sharing in this manner. It’s going to be painful, forever.

I strongly recommend

`forum.cuba-platform.com`

instead

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [May 24, 2018, 9:46am UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/14 "2018-05-24T09:46:14Z")

</div>

Ok, let it be a solution in this quest 🙂. In my case I am not sure that we can move to subdomain, because we are strong 💪 )). Anyway this point may be useful for others who will surf this forum researching subfolder installation tips and tricks!

Thank you for your attention to all questions, very appreciated, @codinghorror!

---

<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: [May 24, 2018, 10:20am UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/15 "2018-05-24T10:20:19Z")

</div>

The problem is we have virtually no customers running this way and we always recommend against it. Furthermore the way you have

```
example.com/content

```

Next to

```
example.com/forum

```

is even _more_ odd … which means this is super rare in the wild. It also does not make sense for us to prioritize any fixes here because none of our customers benefit.

---

<div class="post-metadata">

### Author: ![Ivan\_Rapekas](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ivan_rapekas/32/248924_2.png) [@Ivan\_Rapekas](https://meta.discourse.org/u/Ivan_Rapekas)
#### Post date: [May 24, 2018, 12:08pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/16 "2018-05-24T12:08:22Z")

</div>

Ok, no problem. I realize that we chose our own problem with a subfolder installation, but now it is not reasonable to change it at all. I just used to think that it is possible to resolve this in some regexp in forum code.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 24, 2018, 12:56pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/17 "2018-05-24T12:56:08Z")

</div>

You could try permalink normalization site setting. It’s designed to solve a problem that is at least similar.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [June 8, 2024, 12:37pm UTC](https://meta.discourse.org/t/handle-external-urls-in-topic-body-for-subfolder-installation/75330/18 "2024-06-08T12:37:26Z")

</div>

This topic was automatically closed after 2378 days. New replies are no longer allowed.
