0

I have 2 different WordPress sites on the same server. Both of them contain links to files on our internal network, which are linked using the file:// protocol.

Here is the problem: On one of the sites the file:// links work fine in Internet Explorer; I click the link and the folder location opens in a new window. However, on the other site when I click the file:// links, absolutely nothing happens. What can I do to make this work on both sites?

The site with the working file links is using WordPress version 3.2.1

The site with the non-working file links is using version 3.5.1

Here is an example file:// link that I am having this issue with:

file://servername/sharefolder$/sub1/sub2/sub3
2
  • 2
    Can you give an example of a link that works on one site, but not on the other? (By pasting both links here for comparison, with any private paths replaced) Apr 1, 2015 at 0:58
  • Sure, apologize for not including that. its: file://servername/sharefolder$/sub1/sub2/sub3
    – Randy
    Apr 1, 2015 at 17:24

1 Answer 1

0

Without knowing the full path—or some pseudo-example of the path where you neuter specifics for privacy—hard to say what the issue is. But in general, the file:// URI (uniform resource identifier) scheme requires a hostname. And if there is no host connected to the file:// URI, there should be three slashes (///) and not two (//).

So for example, if you wanted to access a file with the path /hey/there/file on your localhost setup, the URL could be this:

file://localhost/hey/there/file

Or could be this:

file:///hey/there/file

But there could also be an issue with the way WordPress 3.5.1 handles a file:// URI versus how WordPress 3.2.1 would handle it. This small chunklet of code on GitHubGist (from “rosshanney” seems to address the issue by creating a simple plugin method to allow file to be a part of the core kses_allowed_protocols in WordPress:

<?php
/*
Plugin name: Allow file protocol
*/

function rh_allow_file_protocol( $protocols ) {
    $protocols[] = 'file';
    return $protocols;
}

add_filter( 'kses_allowed_protocols', 'rh_allow_file_protocol' )
1
  • Thanks for that Jake, but I've just tried it and it didn't fix the issue. I've added an example of the link that works on the other site in a reply to a comment above.
    – Randy
    Apr 1, 2015 at 17:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .