1

我有这个项目结构 在此处输入图像描述

我将图像保存在文件夹数据/图像中。我想允许通过直接链接访问此文件夹。我的 .htaccess 是

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$
RewriteRule ^(.*)$ - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

怎么做 ?

4

1 回答 1

2

正如评论中所暗示的,您不能简单地通过修改 htaccess 文件来做到这一点,因为您的 images 文件夹位于文档根目录之上。您需要将data/images文件夹移动到,或从到public/images创建符号链接。然后您的图像应该可以在没有任何 htaccess 更改的情况下工作。public/imagesdata/images

于 2013-04-15T15:20:16.810 回答