HOWTO: Linking files from your Windows shared network drives in Wiki
Purpose: So let’s say that you have got your Linux based MediaWiki server going on your internal LAN in your office or corporate intranet. Let’s assume that your intranet is Windows server based which basically means that all the files that you access in your day-to-day work resides on Windows based server. Now one of the common requirement is that when you start creating wiki pages you want to link files that resides on your Windows server on LAN or office intranet. How do you do that?
Let’s get started…
Step 1: Set-up
Let’s say you are using a Windows XP machine on your LAN and you usually access files through Mapped network drivers. For for example, let’s say the there is file that you want to link in your MediaWiki page that you normally access as:
N:\project\docs\howtoconfig.pdf
from your Windows XP machine. Basically the above file (howtoconfig.pdf) resides on some Windows server on your LAN whose driver is mapped as “N” drive on your machine.
Step 2: Enable “file” protocol
Basically if you want to access files from other servers on your LAN (like Windows shares), you can access them using “file” URL protocol. By default MediaWiki does not enable file link protocol. To enable the file protocol make sure you have the following line(s) in your LocalSettings.php
# nano /etc/mediawiki/LocalSettings.php
and add add the following line(s):
$wgUrlProtocols = array(
'http://',
'https://',
'ftp://',
'irc://',
'gopher://',
'telnet://', // Well if we're going to support the above.. -var
'nntp://', // @bug 3808 RFC 1738
'worldwind://',
'mailto:',
'file://',
'news:'
);
As you can see we the line which says “file”.
Step 3: How to link the file
Now with “file” protocol enable, you can link the file like this in your MediaWiki page like this:
[file://N:\project\docs\howtoconfig.pdf]
Save the wiki page and now you can see a hyperlink to your document.
Step 4: Linking files that are not mapped to a network drive
So let’s say another file resides on one of the Windows shares whose path is like this:
\\MyServer\QualityControl\procedure.xls
To link the above file in your Wiki page, do this:
[file://\\MyServer\QualityControl\procedure.xls]
Important Note:
You will notice that the above will work just fine on Internet Explorer. However if you are using FireFox, nothing will happen when you click those links that you just created. The reason is that FireFox by default turns off the “file” protocol for security reasons. You will need to enable that in FireFox. At the time of this writing I am not sure how to do that. Once I find the solution I will make sure to post it. In case if anyone of you figure this out, I would appreciate if you post the procedure in the comment section below.
That’s it! It’s that simple.
Happy Linking!


Email Subscription









February 14th, 2011 at 3:33 am
One way to do it in firefox is to use the ‘locallinks’ extension – this allows you to right click on the link, and open the link locally. This allows you to browse network shares and open files from their location on the network.
Chrome is a different matter entirely – it insists on downloading the file to its downloads folder before opening. Not useful if you’re using it to link to editable/shared documents.
It would be better if firefox and chrome had the same behaviour as IE and would open the links in explorer or open the files using their associated application (and from their network location)
Reply to this comment
April 29th, 2011 at 10:41 pm
I use this:
$wgUrlProtocols = array_merge($wgUrlProtocols, array(‘file://’));
This way you will append the file-protocol instead of overwriting the original array from mediawiki.
Reply to this comment
September 10th, 2012 at 2:33 am
Hi,
How to solve the issue that spaces in the filename isn´t allowed?
%20 didnt worked, either.
Reply to this comment
Sebastian Reply:
February 6th, 2013 at 11:15 am
Hi, i’ve the same issue, did you found any solution to that kind of linking??
Thanks.
Reply to this comment
Markus Reply:
February 25th, 2013 at 12:12 am
Somehow it started to work with %20 not sure why or what I did, sorry!
Reply to this comment