This is a translated page. The original can be found here: http://iwebdevel.com/2009/07/17/apache-modrewrite-how-to-easily-deny-access-to-a-folder-with-htaccess/
UPDATES VIA RSS | Email การปรับปรุงผ่านทาง RSS | Email Get updates via feedburner Get updates via twitter
Home / Apache & mod_rewrite / Coding / Apache & ModRewrite: How… บ้าน / Apache และ mod_rewrite / รหัส / Apache และ ModRewrite: How ...

Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache และ ModRewrite: วิธีง่ายปฏิเสธการเข้าถึงโฟลเดอร์ที่มี htaccess

Posted on 17. โพสต์ใน 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding ก.ค., 2,009 โดย Dragos ใน Apache และ mod_rewrite, รหัส

Working on a project right now I was looking for a solution to protect a folder containing template php files (includes in larger files). ทำงานกับโครงการตอนนี้ฉันถูกมองหาวิธีการป้องกันโฟลเดอร์ที่มีไฟล์เทมเพลท PHP (รวมในไฟล์ขนาดใหญ่). One solution would be to chmod the folder to avoid external meddling of one's curious eyes. หนึ่งโซลูชันจะไป chmod โฟลเดอร์เพื่อหลีกเลี่ยงการแทรกแซงภายนอกตาแปลกใจ. But working with Apache's features I found out that it is more convenient to use the mod_rewrite feature to deny access to a folder and its content. แต่การทำงานกับคุณลักษณะ Apache ของฉันพบว่ามันสะดวกกว่าการใช้ mod_rewrite คุณสมบัติปฏิเสธการเข้าถึงโฟลเดอร์และเนื้อหา. Here's the solution. นี่คือโซลูชั่น. In my case the folder I was trying to protect was templates so my code looked as following (simplified): ในกรณีของฉันโฟลเดอร์ฉันพยายามปกป้อง แม่ จึงเป็นรหัสของฉันดูเป็นต่อไปนี้ (ประยุกต์):


Options +FollowSymLinks
RewriteEngine on
#replace the word templates with the name of your own folder
RewriteRule ^/?templates/?(.*)?$ - [F,L]

Translate this post แปลบทความนี้


Related posts: บทความที่เกี่ยวข้อง:

  1. PHP: Get all files and folders from a directory (folder) PHP: ดูไฟล์และโฟลเดอร์ทั้งหมดจาก directory (โฟลเดอร์)

    blog comments powered by Disqus บล็อกความคิดเห็นขับเคลื่อนโดย Disqus