Link to local/shared files and folders with Drupal
wardk — Wed, 08/24/2011 - 21:13
Local links do not work by default on a Drupal site. After a lot of sifting through misleading posts, I found a way to make local links work for drupal 6. It Works for Drupal 7 too. This post is an attempt to better document the solution.
Local links look like this:
<a href="file://host/share/folder/file.txt">link title</a>.
Notice the "file://"-part in stead of "http://". By default, Drupal will always replace the "file"-part by "http", rendering your local links invalid. The solution is quite simple though. For security reasons the file-protocol is not allowed by default. Adding this or a similar line to your settings.php will solve the problem:
$conf = array('filter_allowed_protocols' => array('http', 'https', 'ftp', 'news', 'mailto', 'file'));
You can add or omit protocols as you see fit.
Most of the time, however, local links are not a good idea. Linking to these files does not make them available to visitors who do not already have access to them through their file browser. Permissions on these files and folders are not managed by Drupal. Renaming or rearranging folders and files will probably break those local links. Also, for security reasons, local links will not work in Mozilla browsers. Linking locally with Drupal is probably only useful for a company intranet, that is only available within the same secure environment in which the network shares to which you are linking are also available.
- Add new comment
- 143 reads