如何设置htaccess以及htpasswd的在我的私人服务器? [英] How to set up htaccess and htpasswd in my private server?

查看:248
本文介绍了如何设置htaccess以及htpasswd的在我的私人服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在尝试设置身份验证我的测试服务器上。

At the moment I'm trying set up authentication on my test server.

以下是文件我试图设置验证文件夹列表中。

The following is the list of files in the folder I'm trying to set up authentication for.

sftp://it@192.168.0.157/var/www/secret/.htpasswd
sftp://it@192.168.0.157/var/www/secret/.htaccess
sftp://it@192.168.0.157/var/www/secret/index.html

下面是什么的.htaccess包含:

Here's what .htaccess contains:

AuthName "Restricted Area"
AuthType Basic 
AuthUserFile /secret/.htpasswd 
AuthGroupFile /dev/null 
<Files test.html>
require valid-user
</Files>

我没有得到登录弹出。它只是显示的index.html当我去192.168.0.157/secret~~V

I'm not getting the login pop up. It simply shows the index.html when I go to 192.168.0.157/secret

我是谁不这样做是否正确?

What am I not doing correctly?

呵呵顺便说一句,请忽视的事实是我没有放在htpasswd的文件更安全的地方。我只想得到这个工作一次,并能证明它。

Oh btw, please ignore the fact that I haven't placed the htpasswd file in a more secure location. I just want to get this to work once and be able to demonstrate it.

推荐答案

您已经指出的URL到FTP服务器,而不是Apache Web服务器。
当试图访问Web服务器,网址为: http://192.168.0.157/secret/index.html

You have stated URLs to a FTP server, not to the Apache web server.
When trying to access webserver, url will be: http://192.168.0.157/secret/index.html

的.htaccess 您已经表示,访问应该是仅适用于的test.html

In .htaccess you have stated that access should be controller only for test.html

使用此的.htaccess控制访问所有文件:

Use this .htaccess for controlling access to all files:

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /secret/.htpasswd
Require valid-user

这篇关于如何设置htaccess以及htpasswd的在我的私人服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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