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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10086989/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 21:21:23  来源:igfitidea点击:

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

phpapache.htaccess

提问by JonE

I have an images folder at the following URL.

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

www.mysite.com/uploads/

On a different page:

在另一个页面上:

www.mysite.com/search.php/

I am trying to access the images wherein, with a correct tag link, however I get the :

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

Forbidden

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

So I went and started dabbling with a .htaccessfile, and I have no idea what I am doing ,I tried looking at some documentation but with no luck, I even took an example off another question..Here is how my .htaccessfile looks atm:

所以我开始涉足一个.htaccess文件,我不知道我在做什么,我尝试查看一些文档但没有运气,我什至拿了另一个问题的例子..这是我的.htaccess文件在 atm 的样子:

<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>

Any ideas on how I can have it allow access to that folder?

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

采纳答案by Explosion Pills

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

回答by Dhruvisha

Give permission in .htaccess as follows:

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

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

回答by user3821381

Having the .htaccess file on the root folder, add this line. Make sure to delete all other useless rules you tried before:

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

Options -Indexes

选项 - 索引

Or try:

或尝试:

Options All -Indexes

选项 All -Indexes