# Link to a UNC path

**URL:** https://meta.discourse.org/t/link-to-a-unc-path/64742
**Category:** Support
**Created:** [2017 年 6 月 19 日午前 9:20 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742 "2017-06-19T09:20:15Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![Pudong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pudong/32/63223_2.png) [@Pudong](https://meta.discourse.org/u/Pudong)
#### Post date: [2017 年 6 月 19 日午前 9:20 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/1 "2017-06-19T09:20:15Z")

</div>

Hello

I use Discourse as a Intranet Forum.  
Now I try to make a Hyperlink to a file on a servershare (\\server.domain.local\share\file.txt).

When I create a link to a UNC path, it appears, but it does not work. When I click on the link nothing happens.

Thats the code I try in Discourse:  
`[My File] (file://///server.domain.local/share/file.txt)`

Is there a way to create a Hyperlink to a UNC Path? Or is it generally not supported?

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2017 年 6 月 19 日午前 9:36 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/2 "2017-06-19T09:36:18Z")

</div>

Have you added “file” to the `allowed href schemes` site setting?

---

<div class="post-metadata">

### Author: ![Pudong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pudong/32/63223_2.png) [@Pudong](https://meta.discourse.org/u/Pudong)
#### Post date: [2017 年 6 月 19 日午前 11:14 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/3 "2017-06-19T11:14:37Z")

</div>

Hi David

That does the trick 😀👍

Thank you!

---

<div class="post-metadata">

### Author: ![\_jf](https://avatars.discourse-cdn.com/v4/letter/_/d9b06d/32.png) [@\_jf](https://meta.discourse.org/u/_jf)
#### Post date: [2017 年 8 月 11 日午後 12:34 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/4 "2017-08-11T12:34:42Z")

</div>

It looks like the updated markdown renderer won’t convert `file://` paths properly ( discourse 1.9.5 )

---

<div class="post-metadata">

### Author: ![Pierre\_GRAND](https://avatars.discourse-cdn.com/v4/letter/p/848f3c/32.png) [@Pierre\_GRAND](https://meta.discourse.org/u/Pierre_GRAND)
#### Post date: [2018 年 11 月 30 日午前 9:57 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/5 "2018-11-30T09:57:08Z")

</div>

Hello,  
I have added file to “allowed href schemes” but when I create a hyperlink using a file:// url, Discourse will post it with https instead of file.  
Then when changing the https back to “file” it’s still opening a https link when clicking on it.

Is the “file” scheme supported in Discourse(I’m in v2.2.0.beta2 +5)?  
br

---

<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: [2018 年 11 月 30 日午後 12:23 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/6 "2018-11-30T12:23:56Z")

</div>

@jomaxro can you verify we didn’t regress on href scheme support?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [2018 年 11 月 30 日午後 5:36 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/8 "2018-11-30T17:36:11Z")

</div>

Can confirm that we did not regress completely, adding `ftp` or `steam` works. I cannot get `file` to work, however, though that could just mean I’m doing something wrong. Never used the file href scheme before.

 ![image](https://global.discourse-cdn.com/meta/original/3X/9/2/92f2520faf8ce12300ac8a6a9af5c893e2dee09e.png)

---

<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: [2018 年 11 月 30 日午後 9:25 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/9 "2018-11-30T21:25:58Z")

</div>

Why are there an unusual number of forward slashes in there? Shouldn’t it be the same pattern for all schemes?

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [2018 年 11 月 30 日午後 9:28 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/10 "2018-11-30T21:28:42Z")

</div>

> [@codinghorror](#):
>
> Why are there an unusual number of forward slashes in there?

No clue. As mentioned, I’ve never seen the file href before. I used 3 for my screenshot as that’s what I saw over on SO: [https://stackoverflow.com/questions/12837024/href-file-doesnt-work](https://stackoverflow.com/questions/12837024/href-file-doesnt-work). In any case, I tried 1 (just in case), 2 (normal), 3 (SO answer), 4, & 5 (example in OP) slashes, none worked.

---

<div class="post-metadata">

### Author: ![Beluk](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@Beluk](https://meta.discourse.org/u/Beluk)
#### Post date: [2019 年 1 月 11 日午後 6:28 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/11 "2019-01-11T18:28:13Z")

</div>

Is there any update on this issue? I run in the same problem using latest version. File is not working as expected.

---

<div class="post-metadata">

### Author: ![user2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/user2/32/135592_2.png) [@user2](https://meta.discourse.org/u/user2)
#### Post date: [2019 年 2 月 4 日午前 6:43 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/12 "2019-02-04T06:43:25Z")

</div>

Hi, I’m trying to use local links to PDF documents on local shared network device. I run Discourse locally as a documentation tool. I have tried to add “file” in the href settings, but cannot get a working local link. Is there any way around this? Is this broken or am I doing it wrong?

---

<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: [2019 年 2 月 4 日午前 8:15 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/13 "2019-02-04T08:15:54Z")

</div>

We should check this again @jomaxro

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [2019 年 2 月 4 日午後 5:42 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/14 "2019-02-04T17:42:33Z")

</div>

Updated my sandbox to 2.3.0.beta1, still not able to get `file` to work. Re-confirmed other custom `href` schemes do still work.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2019 年 2 月 4 日午後 6:23 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/15 "2019-02-04T18:23:40Z")

</div>

It’s weird… `<a href="file://myfile">link</a>` works, but `[link](file://myfile)` does not. But both options work for other custom schemes as @jomaxro said 🤔

Maybe something in the commonmark link internals is stripping out file:// specifically. A quick search doesn’t reveal anything obvious in the discourse codebase.

@user2 the workaround for now is to use the HTML syntax for your link

```plaintext
<a href="file://myfile">link</a>

```

* * *

Edit: even with that, we still have an issue with file:// protocols. It is very common for file paths to start with a `/` (signifying the root of the filesystem), so the link looks like `file:///myfile`. Our sanitizer doesn’t like the three slashes at the beginning, and treats the link as invalid.

---

<div class="post-metadata">

### Author: ![user2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/user2/32/135592_2.png) [@user2](https://meta.discourse.org/u/user2)
#### Post date: [2019 年 2 月 5 日午前 7:08 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/16 "2019-02-05T07:08:10Z")

</div>

> [@david](#):
>
> It is very common for file paths to start with a `/` (signifying the root of the filesystem),

Does this only apply for \*NIX paths?

`file://C:/file.f`  
`file:///var/file.f`

Opened a file in browser and I see `file:///K:/file....`, same on windows. But `<a href="file://myfile">link</a>` does not work either. Maybe it works on \*nix based system but not on windows paths?

This

`<a href="file://C:/test.log">test</a>`

Gives

`domain.tld/clicks/track?url=file%3A%2F%2FC%3A%2Ftest.log&amp;post_id=1103&amp;topic_id=345 ERR_UNSAFE_REDIRECT`

---

<div class="post-metadata">

### Author: ![user2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/user2/32/135592_2.png) [@user2](https://meta.discourse.org/u/user2)
#### Post date: [2019 年 9 月 11 日午前 7:03 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/17 "2019-09-11T07:03:16Z")

</div>

これについて何かニュースはありますか？ 😟

---

<div class="post-metadata">

### Author: ![user2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/user2/32/135592_2.png) [@user2](https://meta.discourse.org/u/user2)
#### Post date: [2022 年 6 月 20 日午前 8:06 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/18 "2022-06-20T08:06:25Z")

</div>

まだ壁に頭を打ち付けています。  
誰かこれを修正する方法を知りませんか？ 😕

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2022 年 7 月 14 日午後 1:59 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/20 "2022-07-14T13:59:34Z")

</div>

Chrome 76（2019年7月）以降、`file://` リンクが完全にブロックされているようです: [Restrictions on File Urls – text/plain](https://textslashplain.com/2019/10/09/navigating-to-file-urls/)

そのため、これはブラウザのセキュリティ制限であり、Discourse側でできることはないと思います。

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [2022 年 7 月 25 日午前 7:00 UTC](https://meta.discourse.org/t/link-to-a-unc-path/64742/21 "2022-07-25T07:00:20Z")

</div>

このトピックは10日後に自動的に閉じられました。返信はもう許可されていません。
