Linking to files not in public html directory

I am using html to create my homepage. I have a bunch of files in a directory that that does not fall under the main html directory (the one with index.html), and I’d like to link to some of them in my html document. Is this possible? Or do I have to move them to the html directory?

Also, will it be a problem if these file names have spaces in them?

Apologies for having to make up terminology (like the “html directory”). Thanks!

All html files that are to be viewed on the web should be in your domain directory. It is possible to have files that are in the private section above your domain folder, but these are usually files that you do not want viewed by the public, such as password files.

My website

Thanks. You say all html files to be viewed must be in the domain directory. But what about non-html files that I want to link to, like, say, an mp3 file of my music that I would like to make downloadable from my homepage?

Also, is there a way to link to files with spaces in them?

all files to be accessed on the web should be in the domain directory. However, you can have sub-folders in the domain directory.

It is ok to have space in the file names. Explorer will automatically convert the space to " ". For example: if the name is “sign out”, it will be “sign out” in the address bar

Save [color=#CC0000]$97[/color] (max discount) on dreamhost plans by using promo code: [color=#CC0000]97CRAZY[/color].

There are ways to do this, but they require an interface of some type (like a download directory/script, document/media repository script, etc.) in order to make files that are “outside” the web-accessible directories available for download. I recommend you save yourself a lot of grief, and just store them in a directory beneath your “base” web accessible directory (/home/yourusername/yourdomainname.tld).

Sure. Just link them, if you insist on doing that. Not all browsers and systems can handle such files well, and they will be a pain to manage on Dreamhost (*nix); it’s a good practice to avoid filenames with spaces for these reasons. Get yourself a “multiple-file/mass renaming” utility (just google) and replace the spaces with the “underline character” ( _ ) and be done with it; you, and your users, will be a lot happier in the long run. :wink:


That is true, for IE and many browsers, but not all, and it makes the files difficult to manage from within the shell on a *nix type system.

I do not recommend using spaces in filenames for files housed on *nix servers - see my previous post’s suggestion for “mass renaming” then to convert the spaces in the filenames to another character. :wink:


Thanks everyone. Your answers give me two more questions.

  1. Is there an easy way to move directory locations on my dreamhost server? I’ve already put 10GB or so of files in a directory outside my domain directory and will need to move them. Or can I easily copy files or directories to different locations on the server?

  2. I’ve used these mass renaming programs before. They’re very convenient. However, is there a way to use them on the dreamhost server (on the 10GB already on there)? My guess is no.

You are welcome. As for your next two questions:

  1. Yes, you can user the “mv” command from the shell’s command line to “move” files from one directory to the other “en masse”. As you mentioned you are going to be moving 10GB of files, make sure and preface the “mv” command with the “nice” command, so that the process will not run afoul of the DH “prockiller” daemon, which monitors the system for programs running too long or consuming too much system resources, and kills such processes when it finds them. There is also the “cp” command for copying files. “mv” differs from “cp” in that “cp” only copies the files (leaving the original file untouched) while “mv” effectively “copies” and then “erases” the original files (leaving no copies of the original files).

Actually, the most general way to “rename” a file in Unix is to “mv” fileA to fileB, effectively “renaming” it, but there other tools available in some distributions (particularly linux) for doing “enhanced” renaming. :wink:

  1. DH’s version of Debian Linux has a “rename” command (actually a perl script), which allows mass re-naming of files using perl-style regular expressions. The program itself is easy enough to use, but you may need to do some research/learning in order to produce an appropriate regular expression to address your particular situation and the filenames you are using. Again, depending upon how many actual filenames you have to manipulate, make sure to “nice” the “rename”, as a courtesy to other users and to avoid your process getting killed.

The use of all these tools is described in detail, and there are many tutorials on their use, in many places on the web - a few carefully run Google searches should provide you with instructions and/or tutorials suitable for your needs and present level of knowledge.


FileZilla can also move files from one directory to another. FileZilla is an ftp program available at
In the remote file directory you can select and drag and drop, just like windows explorer. It seams to only allow moving of files and not folders.

My website

Great. Thanks. I’d kind of avoided trying out sshing into the server, but it works well.

Using the shell can take some getting used to, if you are not comfortable with commandline driven tools, but once you invest in learning how to operate in the shell you can be amazingly productive.

I think it is the single biggest time-saver out there, and access to the shell,and shell tools, is one of DH’s biggest advantages.



You know, there is another approach you could take rather than moving 10 GB worth of files. If all those files are in a directory under your username “adjacent” to your web directory (such as having a directory structure that has /home/username/mediafiledirectory and /home/username/youdomainname.tld) you might find it "easier/faster to “copy” or “move” (or even download) the files in your /home/username/yourdomainname.tld directory to a “temporary” location, and then just “rename” your /home/username/mediafiledirectory to /home/username/yourdomainname.tld.

Once you do that, just re-upload, or copy/move the “html” files you stored temporarily into that “new” /home/username/youdomainname.tld directory (which now already contains all your media files) and you are all set, with everything you need in a web accessible directory.

There are several variations on that concept that would work, including just moving the contents of your “web” base directory into you media directory, and then renaming, or moving you r media directory into a "sub-directory of itself, and then moving the html into the “parent” of the new media directory (the “old” media directory) and then renaming it to be your base “web” directory - I think you get the idea here.

I’ll guarantee you it will be a lot quicker/simpler to use any of those methods (involving moving only the few files that comprise the contents of your “web” directory) than to move 10GB of files from your “media” directory to a new location. :slight_smile:


Regarding the question about spaces in filenames, spaces are not legal in URLs unless they’re encoded in hexadecimal with a percent sign, which makes for really ugly URLs. If you just link them directly as some others in this thread have advocated, you are using invalid code and it might not work in all browsers. Not everybody is using Internet Explorer for Windows.

– Dan