【发布时间】:2013-12-09 15:12:55
【问题描述】:
我的目录结构如下:
root
--/inc
--/img
--/docs
---/public
----/contact
-----/img
------telephone.jpg
-----contact.php
---/private
我的目标是使“文档”下的每个文件夹成为“包含”网页。每个文件夹都有自己的/img/ 文件夹和一个/bin/ 文件夹,其中可以包含从Mp3s 到PDF 的任何内容。
目前我正在将所有内容路由到 index.php,然后从那里手动重定向文件。但事实证明这是非常缓慢的。如果说试图通过/contact/telephone.png 访问图像,我认为会更快的是我的 .htaccess 中的类似内容:
try /img/{url_path}
Otherwise, try /docs/$1/img/$2
Otherwise route through index.php
我该怎么做呢?目前我的 .htaccess 如下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# if file not exists
RewriteCond %{REQUEST_FILENAME} !-f
# if dir not exists
RewriteCond %{REQUEST_FILENAME} !-d
# avoid 404s of missing assets in our script
#RewriteCond %{REQUEST_URI} !^.*\.(jpe?g|png|gif|css|js)$ [NC]
RewriteRule .* index.php [QSA,L]
</IfModule>
任何帮助表示赞赏!谢谢
【问题讨论】:
标签: .htaccess