Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to re-organize our web server and segregate download-able files from the HTML/content of the site. I have setup a "data" directory like so:

    /pdf, /image, /audio, etc...
    /pdf, /image, /audio, etc...

So everything in /public is fully accessible, everything in /protected is behind ModAuth.

My question is, is there anyway to directly link files from within the "file-type" sub-directories? This would make all URLs of the form "/public/something.jpg" or "/private/mydoc.pdf" without the need for subdirectories in the URL. However, I still want to use the subdirectories for my own organization.

This is not a very big issue, just something I got curious about as I started working on this.

share|improve this question
up vote 1 down vote accepted

This would be a job for mod_rewrite:

Or, perhaps more on SF:

Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

You'd have something along the lines of:

RewriteEngine On
RewriteRule /public/(.*)\.jpg        /public/image/$1.jpg
RewriteRule /public/(.*)\.pdf        /public/pdf/$1.pdf

and so on, for however many types you have.

share|improve this answer
thanks this is exactly what i was looking for. – Alex Ciarlillo May 29 '12 at 16:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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