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威盛最新的RSS | 电子邮件 Get updates via feedburner Get updates via twitter
Home / Apache & mod_rewrite / Coding / Apache & ModRewrite: How… 首页 / Apache和mod_rewrite的 / 编码 / Apache和ModRewrite:如何...

Apache & ModRewrite: How to easily deny access to a folder with htaccess 阿帕奇&ModRewrite:如何轻松拒绝访问与htaccess的文件夹

Posted on 17.发布17。 Jul, 2009 by Dragos in Apache & mod_rewrite , Coding 2008年7月,2009年在阿帕奇 德拉戈什 和mod_rewrite的 编码

Working on a project right now I was looking for a solution to protect a folder containing template php files (includes in larger files).在一个项目的工作,现在我一直在寻找一个解决方案来保护文件夹中包含的模板php文件(包括在较大的文件)。 One solution would be to chmod the folder to avoid external meddling of one's curious eyes.一个解决办法是和chmod的文件夹,以避免人们的好奇的眼睛外部干涉。 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.但是,与Apache的特点,我发现,它更方便地使用mod_rewrite的功能来拒绝访问的文件夹及其内容。 Here's the solution.这里的解决方案。 In my case the folder I was trying to protect was templates so my code looked as following (simplified):在我的情况下,文件夹,我试图保护的模板 ,我的代码看起来如下(简化):


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

Translate this post翻译这个职位


Related posts:相关岗位:

  1. PHP: Get all files and folders from a directory (folder) PHP的:获取所有从一个目录(文件夹的文件和文件夹)

    blog comments powered by Disqus 博客评论 Disqus