All about unix linux freebsd and FAQ for Packetlove.com Web hosting , Mail hosting , VoIP + IP PBX server > All Security via cyber space relate golfreeze task.

เขียนกัน ไม่ให้ folder images สามารถเรียกไฟล์ php , dll , ได้

(1/1)

golfreeze:
เขียนกัน ไม่ให้ folder images สามารถเรียกไฟล์ php , dll , ได้

#cd images
#vi .htaccess
<Files ~ "\.(inc|sql|php|htm|html|asp|jsp|exe|zip|rar|dll)$">
  order allow,deny
  deny from all
</Files>

แล้วปรับ folder เป็น 755
#chmod 755 images

golfreeze:
ในกรณีถ้าใช้งาน wordpress แล้วต้องการ upload file เข้าระบบ เราต้องปรับสิทธิ์ให้กับ user นั้นๆ

แต่ถ้ากังวลว่าจะโดนเรียกใช้งาน script php ผ่าน folder uploads ก็สามารถเขียนกันได้ดังนนี้ ครับผม

#cd  /home/customer/public_html/wp-content/uploads
#vi .htaccess

<FilesMatch "\.(php|php\.)$">
Order Allow,Deny
Deny from all
</FilesMatch>

#chown root:root .htaccess

แค่ก็กันไม่ให้เรียกใช้งาน script .php ใน folder uploads ละครับ

golfreeze:
หรือจะเขียนให้ อนุญาตแค่ ไฟล์ตระกูลรูปภาพ ที่เหลือ deny ทั้งหมดก็
order allow,deny
<Files ~ "\.(jpg|jpeg|png|gif|pdf|txt|bmp)$">
   allow from all
</Files>

นำร่อง

[0] ดัชนีข้อความ

Go to full version