使用Apache来组织和托pipe静态文件(下载)?

我试图重新组织我们的networking服务器,并从网站的HTML /内容中分离出可下载的文件。 我已经build立了一个“数据”目录,如下所示:

/data /public /pdf, /image, /audio, etc... /protected /pdf, /image, /audio, etc... 

因此,/ public中的所有内容都是完全可访问的,所有/ protected中的内容都在ModAuth之后。

我的问题是,是否有直接链接“文件types”子目录内的文件? 这将使所有url的forms“/public/something.jpg”或“/private/mydoc.pdf”,而不需要URL中的子目录。 但是,我仍然想为我自己的组织使用子目录。

这不是一个很大的问题,只是我开始研究这个问题而感到好奇。

这将是一个mod_rewrite的工作:

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

或者,也许更多关于SF:

redirect,更改URL或redirectHTTP到HTTPS的Apache – 你想知道的所有关于Mod_Rewrite规则,但不敢问

你会有以下几点:

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

等等,不pipe你有多lesstypes。