Hướng dẫn tạo Password Protect thư mục trên Linux

Lê Châu Hải My 1 phút đọc

Để thiết lập Password Protect cho một thư mục trên Linux (VD: Thư mục /home/user/public_html/administrator).

Các bạn nên thực hiện các bước ví dụ như sau:

1. Tạo file .htaccess lưu trong thư mục administrator cần bảo mật, thiết lập user cho phép truy cập:

AuthUserFile /home/user/passwdadmin
AuthGroupFile /dev/null
AuthName “NHẬP USER @user và Password @password ĐỂ VÀO TRANG WEB”
AuthType Basic
<Limit GET>
require user @user
</Limit>

2. Tạo file /home/user/passwdadmin (Có thể tạo trên cPanel):

  • Vào link: htaccesstools.com
  • -> Nhập User : @user và Password : @password
  • Copy nội dung đã Generator vào file /home/user/passwdadmin
  • Lúc này: Khi truy cập vào website sẽ xuất hiện một Dialog thông báo nhập User và Password.
    => Hoàn tất bảo mật folder trên Linux.