简体   繁体   English

图像查看时的HTTP基本身份验证(.htaccess)

[英]HTTP Basic Auth Upon Image View (.htaccess)

I saw this and I'd love to know how to recreate it. 我看到了这个,我很想知道如何重新创建它。 Unfortunately, I don't know .htaccess. 不幸的是,我不知道.htaccess。

Upon viewing an image, there was an HTTP Basic Auth style dialog that asked to enter some sort of authentication (albeit nothing actually submitted anywhere). 查看图像后,出现一个HTTP Basic Auth样式对话框,要求输入某种身份验证(尽管实际上未在任何地方提交)。

I'm sorry for the skid question, but I'd really love some insight as to how this can be done using .htaccess or .htpasswd. 对于这个问题,我感到很抱歉,但是我真的很喜欢可以使用.htaccess或.htpasswd做到这一点的见解。

Thanks. 谢谢。

In your apache site conf, add something like: 在您的apache网站conf中,添加以下内容:

Alias /image /path/to/img
 <Directory "/path/to/img">
     AuthType Basic
     AuthName "LoginImage"
     AuthUserFile /path/to/.htpasswd
     Require valid-user
  </Directory>

Then, create the .htpasswd file with: 然后,使用以下命令创建.htpasswd文件:

htpasswd -c .htpasswd someusername

and you'll be prompted to create a password. 并提示您创建密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM