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 Липень, 2009 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]
Related posts: Схожі повідомлення:












































