.htaccess文件,以允许访问图像文件夹以查看图片


.htaccess file to allow access to images folder to view pictures?

我在以下URL有一个图像文件夹。

www.mysite.com/uploads/

在其他页面上:

www.mysite.com/search.php/

正在尝试使用正确的标签链接访问其中的图像,但是我得到:

Forbidden
You don't have permission to access /uploads/ on this server. 

所以我去开始涉足一个.htaccess文件,我不知道我在做什么,我尝试查看一些文档但没有运气,我什至从另一个问题中举了一个例子。以下是我的.htaccess文件的外观:

<FilesMatch "'.(gif|jpe?g|png)$">
Order allow,deny
Allow from all
</FilesMatch>
<Directory /uploads>
# All access controls and authentication are disabled
# in this directory
Satisfy Any
Allow from all
</Directory>

关于如何让它允许访问该文件夹的任何想法?

<Directory /uploads>
   Options +Indexes
</Directory>

在 .htaccess 中授予权限,如下所示:

<Directory "Your directory path/uploads/">
Allow from all
</Directory>

在 images 文件夹中创建一个 .htaccess 文件并添加这个

<IfModule mod_rewrite.c>
RewriteEngine On
# directory browsing
Options All +Indexes
</IfModule>

您可以将此Options All -Indexes放在项目文件.htaccess ,file 中以拒绝直接访问其他文件夹。

这做你想做的事

将 .htaccess 文件放在根文件夹上,添加此行。确保删除您之前尝试过的所有其他无用规则:

选项 -索引

或尝试:

选项 all -索引