Anda di halaman 1dari 2

Review htaccess

memproteksi halaman web dengan login user

cara : menambahkan authentication pada Directive : Directory


pada apache

skenario : membuat user login untuk website : elearning .tkj


data :
ServerName :elearning.tkj
DocumentRoot : /var/www/elearning

element value
<html bgcolor="red">
properties

<Directory "var/www/elearning">
AuthType Basic
AuthName "Restricted Content"
AuthUserFile/etc/apache2/.htpasswd - data yg sudah diinput akan dicek
disini
Require valid-user
</Directory>

membuat user htpasswd


sintax : htpasswd -c <lokasi simpan.htpasswd> nm_user_baru

contoh :
nama file passwd : .htpasswd
lokasi : /etc/apache2
user : user1

menampilkan file hiden : ls -al

htpasswd (tanpa -c)<{digunakan untuk memperbarui / replace} /etc/apache2/.htpasswd


user1

Riquire valid-user
-> yg bisa akses hanya user yang sudah terdaftar
-> semua user yang terdaftar bisa login

untuk membatasi user tertentu dari user yang telah ada


Riquire user <nm_user1> <nm_user2> ...

-> yang boleh akses adalah user1 dan user2

Cara 2 :
membuat configurasi protek folder pada file .htaccess

data :
ServerName :elearning.tkj
DocumentRoot : /var/www/elearning
konfigurasi tambahkan :

<Directory "var/www/elearning">
// konf file yg ada disini bisa diganti file lain
AllowOverride ALL
</Directory>

//Redirect URL
->MEMINDAHKAN URL yang diakses ke URL lain
contoh :
diakses : http://elearning.tkj
redirect : http://openchart.tkj

syarat :
-pastikan module apache Rewrite on

Cek module apache aktif


-etc/apache2/mod-enable

Perintah Redirect

RewriteEngine on
RedirectMatch ^/$ http://openchart.tkj

Anda mungkin juga menyukai