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 MISES A JOUR VIA RSS | Email Get updates via feedburner Get updates via twitter
Home / Apache & mod_rewrite / Coding / Apache & ModRewrite: How… Accueil / Apache & mod_rewrite / Codage / Apache & ModRewrite: Comment ...

Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Comment nier facilement accès à un dossier avec htaccess

Posted on 17. Posté le 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding Jul, 2009 par Dragos dans Apache et 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). Travaille sur un projet en ce moment je cherchais une solution pour protéger un dossier contenant les fichiers de modèle php (comprend les plus gros fichiers). One solution would be to chmod the folder to avoid external meddling of one's curious eyes. Une solution serait de faire un chmod sur le dossier pour éviter l'ingérence extérieure de nos yeux curieux. 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. Mais travailler avec des fonctionnalités d'Apache, j'ai découvert qu'il est plus pratique d'utiliser le mod_rewrite fonctionnalité pour refuser l'accès à un dossier et son contenu. Here's the solution. Voici la solution. In my case the folder I was trying to protect was templates so my code looked as following (simplified): Dans mon cas, le dossier que j'essayais de protéger était modèles afin mon code regardé comme suit (simplifié):


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

Translate this post Translate this post


Related posts: Related posts:

  1. PHP: Get all files and folders from a directory (folder) PHP: Obtenir tous les fichiers et dossiers à partir d'un répertoire (dossier)

    blog comments powered by Disqus Commentaires Blog powered by Disqus