2

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:

/data
  /public
    /pdf, /image, /audio, etc...
  /protected
    /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.

1 Answers1

1

This would be a job for mod_rewrite:

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

Or, perhaps more on SF:

Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - 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.

cjc
  • 24,533
  • 2
  • 49
  • 69