Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Menggunakan .htpasswd dan .htaccess pada Apache 
 

 

.htpasswd digunakan untuk proteksi akses web , kecuali oleh user tertentu. User tersebut akan dimintai user name dan password apabila mengakses halaman web tersebut. Berikut langkah - langkah menggunakan .htpasswd pada Apache : 

1. membuat file user dan password nya

berikut adalah membuat file user dan password dengan nama file "user" . 

        root@bsd /usr/local/apache/bin > ./htpasswd -c /home/tahupecel/users/user wus
        New password:
        Re-type new password:
        Adding password for user wus


Untuk menambahkan user yang lain ( tidak perlu menggunakan option -c ), apabila option -c digunakan maka file .htaccess akan overwritten .

       root@bsd /usr/local/apache/bin > ./htpasswd /home/tahupecel/users/user ipin
       New password:
       Re-type new password:
       Adding password for user ipin



2. membuat file .htaccess

misalkan kita akan proteksi akses yang ada pada folder /home/tahupecel , maka kita buat file .htaccess dalam folder tersebut. Yang berisi :

       AuthName "Kamu harus masukkan password untuk akses halaman ini !!"
       AuthType Basic
       AuthUserFile /home/tahupecel/users/user
       require valid-user


Bila pingin merubah satu user saja yg bisa akses, ganti bagian ini (contoh hanya untuk user wus) :

       require user wus

3. Edit file httpd.conf pada bagian berikut ini :

       AllowOverride AuthConfig
               ....................
       AccessFileName .htaccess
               ....................
       <Files ~ "^\.ht"> 
       Order allow,deny 
       Deny from all 
       </Files> 
               ...................

4. Restart Apache        

       root@bsd ~ > /usr/local/apache/bin/apachectl restart
       /usr/local/apache/bin/apachectl restart: httpd restarted
       root@bsd ~ >

 

G-net Pekalongan, July 25 2002 by esteh

Back to INDEX