아파치 웹서버에 접근 제한을 위해서 .htaccess 파일을 사용하는 방법은 다음과 같습니다.
1. 접근 제한을 사용할 폴더의 설정 변경
아파치 웹서버의 httpd.conf 파일에서 접근 제한을 사용할 폴더의 설정을 다음과 같이 수정한다.
<Directory "/var/www/awstats">
Options Indexes FollowSymLinks MultiViews
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
2. 아파치 웹서버를 다시 시작한다.
3. 접근 제한 폴더의 사용자 및 비밀번호 파일을 생성한다.
터미널에서 아래와 같이 실행하여서 접근 제한 폴더의 사용자 및 비밀번호를 설정한다.
# htpasswd -bcm /var/www/passwords {사용자} {비밀번호}
# htpasswd -bcm /var/www/passwords root 1234
4. 접근 제한 폴더에 .htaccess 파일을 생성한 후, 아래와 같이 입력한다.
AuthName "protected website"
AuthType Basic
AuthUserFile /var/www/passwords
require user root
[참고자료] http://linuxconfig.org/apache-htaccess-directory-access-protection
출처 : https://blog.naver.com/websearch/220424670091