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 Aggiornamenti via RSS | Email Get updates via feedburner Get updates via twitter
Home / Apache & mod_rewrite / Coding / Apache & ModRewrite: How… Home / Apache e mod_rewrite / Coding / Apache & ModRewrite: Come ...

Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Come facilmente negare l'accesso a una cartella con htaccess

Posted on 17. Posted on 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding Luglio, 2009 da Dragos in Apache e 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). Lavorando su un progetto proprio adesso che stavo cercando una soluzione per proteggere una cartella contenente i file di modello php (include nel file di dimensioni maggiori). One solution would be to chmod the folder to avoid external meddling of one's curious eyes. Una soluzione potrebbe essere quella di chmod la cartella al fine di evitare interferenze esterne agli occhi curiosi. 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. Ma lavorando con le caratteristiche di Apache ho scoperto che è più conveniente utilizzare la funzionalità di mod_rewrite per negare l'accesso a una cartella e il suo contenuto. Here's the solution. Ecco la soluzione. In my case the folder I was trying to protect was templates so my code looked as following (simplified): Nel mio caso la cartella che stavo cercando di proteggere i modelli è stato quindi il mio codice guardato come segue (semplificato):


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

Translate this post Traduci questo post


Related posts: Related posts:

  1. PHP: Get all files and folders from a directory (folder) PHP: Ottieni tutti i file e le cartelle da una directory (cartella)

    blog comments powered by Disqus commenti del blog powered by Disqus