This is a translated page. The original can be found here: http://iwebdevel.com/2009/07/17/apache-modrewrite-how-to-easily-deny-access-to-a-folder-with-htaccess/
UPDATES VIA RSS | Email Opdateringer via RSS | E-mail Get updates via feedburner Get updates via twitter
Home / Apache & mod_rewrite / Coding / Apache & ModRewrite: How… Hjem / Apache & mod_rewrite / Kodning / Apache & ModRewrite: Hvordan ...

Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Hvordan nemt nægte adgang til en mappe med htaccess

Posted on 17. Sendt den 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding Juli, 2009 af Dragos i Apache & mod_rewrite, Kodning

Working on a project right now I was looking for a solution to protect a folder containing template php files (includes in larger files). Arbejder på et projekt lige nu jeg var på udkig efter en løsning til at beskytte en mappe, der indeholder skabelon php filer (også 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 at chmod mappen for at undgå ekstern indblanding af ens nysgerrige øjne. 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 arbejdet med Apache's funktioner, jeg fandt ud af, at det er mere praktisk at bruge mod_rewrite funktion til at nægte adgang til en mappe og dens indhold. 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 mit tilfælde den mappe jeg forsøgte at beskytte var skabeloner, så min kode så ud som følgende (forenklet):


Options +FollowSymLinks
RewriteEngine on
#replace the word templates with the name of your own folder
RewriteRule ^/?templates/?(.*)?$ - [F,L]

Translate this post Oversæt dette indlæg


Related posts: Relaterede stillinger:

  1. PHP: Get all files and folders from a directory (folder) PHP: Få alle filer og mapper fra et bibliotek (mappe)

    blog comments powered by Disqus blog comments powered by Disqus