Windows – How to instruct Firefox to allow me to open file:/// URLs on a localhost-server http:// webpage

browserfirefoxwindows

I have made a WWW control panel running on http://127.0.0.1/.

When I open it in Firefox and click a link such as:

<a href="file:///C:/Users/John%20Doe/Documents/test/log.txt">test</>

Nothing happens. Why doesn't it open the file:/// URL, whether it be in Firefox or with my OS-specified (or Firefox-specified) .txt handler application? It used to work when I was using an RSS client instead of my browser for this (it opened Notepad++ and went to the right file).

Why doesn't Firefox do anything whatsoever? It doesn't even dump any kind of error message in the "Console" of Firefox, which usually happens whenever there is some issue like this.

Nope. Nothing. It just doesn't care about the URL.

In spite of the lack of any error, I suspect it has something to do with not getting to mix file:/// URLs in a http://-served webpage or something. If so, is there perhaps some nice "meta tag" or something I can use to instruct Firefox that yes, I want this particular page to be allowed to open file:/// URLs?

Best Answer

Shamelessly stealing from my answer on StackOverflow:

Links to local files on pages that were retrieved via HTTP(S) are deliberately disabled in Mozilla/Firefox, because they can be a security risk, and have been used in attacks in the past.

You can override this behaviour, however.

Short version:

You need to configure Firefox' Security Policy to allow links to local files. This can be done either using the configuration file policies.json (all platforms), or by using Windows Group Policies (only on MS Window).

In both cases, the setting to change is LocalFileLinks - it contains a list of domains where links to local files are allowed.

Example policies.json:

{
  "policies": {
    "LocalFileLinks": ["http://example.org/",
                       "http://example.edu/"]
  }
}

For details, see this article in MozillaZine, and How to access the local filesystem from a webpage in Firefox on Mozilla Support.

Related Question