Is there any way to create a symbolic link to a URL?

Update: I need to symlink it to an HTTP URL.

Update: The reason I want to do this is so that I can move this symlink to another computer without having to copy the file itself (it's big), and instead, the other computer will just use the online copy from the URL.

link|improve this question
1  
URL's have little to do with HTTP (assuming that's what's implied). That's why it's explicitly http:// at the beginning. You need to be more specific. Wouldn't just mounting WebDAV do, using davfs, again assuming you're on Linux? – Daniel Beck Apr 29 '11 at 20:26
What do you want to do? Should a browser open if you click it? Or why you need such a link? – binfalse Apr 29 '11 at 20:27
1  
You still haven't told us the protocol this is about. It could as well be file://, indicating a path on the local file system, http://, https://, ftp://, svn://, etc. – Daniel Beck Apr 29 '11 at 20:34
1  
It is an http:// url – Anonymous Apr 29 '11 at 20:37
Consider using WebDAV. Otherwise, most systems allow the storing of URL references, e.g. .url files on Windows or .webloc files on Mac OS X. – Daniel Beck Apr 29 '11 at 20:44
show 1 more comment
feedback

3 Answers

up vote 4 down vote accepted

It's not possible to create a symlink to an URL. If you can make executables and the target OS is Linux-alike, you can create a file which opens the URL as in:

#!/bin/sh
x-www-browser 'http://example.com/your/link'
link|improve this answer
feedback

It's not possible to link to a HTTP location. You might be able to mount the location of this file via WebDAV to your system and link to the local mount, but this only works if it's configured to get exported via WebDAV..
But if you want to read the file (I think you are trying to do so), you anyhow have to download the content (even if it would be possible to create such a link). So I recommend to simply download it.

link|improve this answer
But if you download it and it changes, your downloaded copy is out of date. – endolith Apr 6 at 14:29
feedback

As people have explained, although you can create a symlink that links to an URL, it does not accomplish much. UNIX is not smart enough to look at the link content, recognize it as an URL, and then do something appropriate to it.

Nevertheless, I occasionally do create symlinks to URLs. Mainly just as documentation - I am used to going to looking at ~/links/* when I forget where, on the filesystem, I have stored something. It's not much of a stretch to do the same thing for URLs. However, doing so tends to break consistency checks and other stuff that assumess or requires that symlinks point to valid filesystem locations.

Furthermore, I have made some of my own tools smart enough to recognize that, if they see a symlink where an URL is needed, that they should dereference the symlink and look at its contents. More and more of my tools treat URLs and paths in the filesystem as interchangeable. Assuming, of course, that the URL protocol has appropriate methods for reading and writing.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.