Friday, March 9, 2012

enabling .htaccess and make it protect your web directory

ໃຫ້ໄປເບິ່ງ config ໃນ httpd.conf ວ່າຖືກເອີ້ນໃຫ້ໃຊ້ງານໄດ້ຫລືບໍ່ ດ້ວຍການຊອກຫາ AccessFileName ວ່າມັນຊີ້ໄປຫາຟາຍ .htaccess ຫລືບໍ່

ຕົວຢ່າງ
[root@luc1f3r assholy]# grep -i AccessFileName /etc/httpd/conf/httpd.conf
# AccessFileName: The name of the file to look for in each directory
AccessFileName .htaccess


ຕໍ່ມາກໍ່ຊອກວ່າມັນຖືກເປີດໃຊ້ຈາກ apache ແລ້ວຫລືບໍ່ ຈາກ configure ຂອງ httpd.conf ຄືເກົ່າ

[root@luc1f3r assholy]# grep -i AllowOverride /etc/httpd/conf/httpd.conf
# AllowOverride controls what directives may be placed in .htaccess files.
AllowOverride None


ສັງເກດ AllowOverride ທາງເຖິງຈະເປັນ None ໃຫ້ປ່ຽນເປັນ all
ຫລັງຈາກປ່ຽນແລ້ວຢ່າລືມ restart apache
service httpd restart

ສ່ວນນີ້ຄືຕົວຢ່າງການຕັ່ງຄ່າ .htaccess
#ແບບໃຫ້ຖາມຫາ user&password
AuthUserFile /var/www/html/assholy/.htpasswd
AuthGroupFile /dev/null
AuthName "Password Protected Area"
AuthType Basic


#####ທາງລຸ່ມໃຫ້ເອົາ# ອອກ
<#limit get="" post="">
require valid-user
<#/limit>


ສັງເກດທາງເທິງມັນຈະໄປກວດກາ user pass ຢູ່ໃນ .htpasswd ເຮົາສາມາດສ້າງໄດ້ຈາກ shell ໃນ linux

htpasswd -c /PATHTOYOURDIRECTORY/.htpasswd myuser
New password:
Re-type new password:
Adding password for user myuser


ຫລືໃຜສັບສົນ ສາດມາດໃຊ້web generate ເອົາກໍ່ໄດ້
http://cooletips.de/htaccess/
http://www.webmaster-toolkit.com/htaccess-generator.shtml
#ແບບອະນຸຍາດຕາມ source IP
Order deny,allow
Deny from all
Allow from 192.168.0.0/24

No comments: