Apache & ModRewrite: How to easily deny access to a folder with htaccess אפאצ 'י & ModRewrite: כיצד בקלות למנוע גישה לתיקיה עם htaccess
Posted on 17. פורסם ב 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding יולי, 2009 על ידי Dragos ב אפאצ 'י & 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. אבל עבודה עם תכונות של אפאצ 'י גיליתי שזה נוח יותר להשתמש בתכונה 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]
Related posts: הודעות קשורות:












































