Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Hoe gemakkelijk toegang weigeren aan een map met htaccess
Posted on 17. Geplaatst op 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding Juli, 2009 door Dragos in Apache en mod_rewrite, Coding
Working on a project right now I was looking for a solution to protect a folder containing template php files (includes in larger files). Werken aan een project nu was ik op zoek naar een oplossing ter bescherming van een map met sjabloon php-bestanden (ook in grotere bestanden). One solution would be to chmod the folder to avoid external meddling of one's curious eyes. Een oplossing zou zijn om de map chmod op externe inmenging van je nieuwsgierige ogen te vermijden. 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. Maar werken met functies Apache's kwam ik erachter dat het handiger om de mod_rewrite functie om toegang tot een map en de inhoud ervan te ontkennen. Here's the solution. Hier is de oplossing. In my case the folder I was trying to protect was templates so my code looked as following (simplified): In mijn geval de map die ik probeerde te beschermen werd sjablonen dus mijn code keek als volgt (vereenvoudigd):
Options +FollowSymLinks
RewriteEngine on
#replace the word templates with the name of your own folder
RewriteRule ^/?templates/?(.*)?$ - [F,L]
Related posts: Gerelateerde berichten:












































