Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Slik lett nekte tilgang til en mappe med htaccess
Posted on 17. Posted on 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding Jul 2009 av Dragos i Apache & 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). Arbeider med et prosjekt nå jeg var ute etter en løsning for å beskytte en mappe som inneholder mal php-filer (inkluderer i større filer). One solution would be to chmod the folder to avoid external meddling of one's curious eyes. En løsning ville være å chmod mappen for å unngå ekstern innblanding av ens nysgjerrige øyne. 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. Men arbeidet med Apache funksjoner jeg fant ut at det er mer praktisk å bruke mod_rewrite funksjonen til å nekte tilgang til en mappe og dens innhold. Here's the solution. Her er løsningen. In my case the folder I was trying to protect was templates so my code looked as following (simplified): I mitt tilfelle mappen jeg prøvde å beskytte var maler så koden min så ut som følgende (forenklet):
Options +FollowSymLinks
RewriteEngine on
#replace the word templates with the name of your own folder
RewriteRule ^/?templates/?(.*)?$ - [F,L]
Related posts: Relaterte artikler:












































