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 от Драгош в 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: Свързани пунктове:












































