Handle external urls in topic body for subfolder installation


(Ivan Rapekas) #1

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.


(Jay Pfaffman) #2

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.


(Neil Lalonde) #3

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

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


(Jay Pfaffman) #4

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.


(Ivan Rapekas) #5

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

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 :wink:. 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. 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.

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! :slightly_smiling_face:


(Jay Pfaffman) #6

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


(Tymofii Pavliuk) #7

Hi, guys!

We have forum installed in subfolder: i.materialise
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.


(Ivan Rapekas) #8

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.

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

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-4-webinar

(Neil Lalonde) #9

I have a live demo of it working for me here using the above example.


(Ivan Rapekas) #10

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!


(Ivan Rapekas) #11

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


(Ivan Rapekas) #12

Hello,

this is still a bug, yesterday checked on v2.0.0.beta10 +117. 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 :persevere:. I even tried to use Saved searches to catch possible broken URLs, this made me a happy zombie-watcher :zombie:.

Please fix it for subfolder installation…


(Jeff Atwood) #13

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


(Ivan Rapekas) #14

Ok, let it be a solution in this quest :slight_smile:. In my case I am not sure that we can move to subdomain, because we are strong :muscle: )). 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!


(Jeff Atwood) #15

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.


(Ivan Rapekas) #16

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.


(Jay Pfaffman) #17

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