.htaccess密码保护目录,但允许图像文件类型 [英] .htaccess password protect directory but allow image file types

查看:83
本文介绍了.htaccess密码保护目录,但允许图像文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用.htaccess密码保护目录,此操作已成功完成。但是网站的前端被编程为链接到受密码保护的目录中的图像(不是我本人),但是当网页尝试访问这些图像时,它会提示用户登录。

I need to password protect a directory with .htaccess, which I have successfully done. But the front end of the website was programmed to link to images within this password protected directory (not by me), but when a webpage tries to access those images it prompts the user to login.

是否可以用密码保护该目录,但允许对* .jpg和* .gif之类的任何图像文件类型进行任何访问?

Is it possible to password protect that directory, but allow any access to any image file type like *.jpg and *.gif?

我的当前帐户。 htaccess代码是这样的:

My current .htaccess code is this:

AuthName "Secure Area"
AuthUserFile "/home/siteuser/.htpasswds/public_html/admin/passwd"
AuthType Basic
require valid-user

感谢任何

推荐答案

AuthName "Secure Area"
AuthUserFile "/home/siteuser/.htpasswds/public_html/admin/passwd"
AuthType Basic
require valid-user
<FilesMatch "\.(png|jpe?g|gif)$">
  Satisfy Any
  Allow from all
</FilesMatch>

编辑以合并Shef的改进

Edit to incorporate Shef's improvement

这篇关于.htaccess密码保护目录,但允许图像文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆