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 Actualizacións Via RSS | Email Get updates via feedburner Get updates via twitter
Home / Apache & mod_rewrite / Coding / Apache & ModRewrite: How… Home / Apache e mod_rewrite / Codificación / Apache & Modrewrite: Como ...

Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & Modrewrite: Como facilmente negar o acceso a unha carpeta con htaccess

Posted on 17. Posta en 17. Jul, 2009 by Dragos in Apache & mod_rewrite , Coding Xullo de 2009 por Dragos en 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). Traballando nun proxecto agora que eu estaba a buscar unha solución para protexer unha carpeta que contén ficheiros dun modelo php (inclúe en arquivos maiores). One solution would be to chmod the folder to avoid external meddling of one's curious eyes. Unha solución sería a de chmod na carpeta para evitar a vexa comprometida externa dun dos ollos curiosos. 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. Pero traballar coas características do Apache eu descubrir que é máis conveniente usar o mod_rewrite recurso para negar acceso a unha carpeta, eo seu contido. Here's the solution. Aquí está a solución. In my case the folder I was trying to protect was templates so my code looked as following (simplified): No meu caso a carpeta que eu estaba intentando protexer estaba modelos para o meu código mirou como segue (simplificado):


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

Translate this post Traducir esta post


Related posts: Related posts:

  1. PHP: Get all files and folders from a directory (folder) PHP: Pega todos os arquivos e directorios dun directorio (carpeta)

    blog comments powered by Disqus blog comments powered by Disqus