的.htaccess:prevent访问文件和prevent目录浏览 [英] .htaccess: prevent access to files and prevent directory browsing

查看:186
本文介绍了的.htaccess:prevent访问文件和prevent目录浏览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想prevent所有的文件访问和目录浏览的目录没有放在.htaccess文件中说的目录。

I want to prevent all file access and directory browsing for a directory without putting a .htaccess file in said directory.

例如,让我们说这是我的根Web目录:

For example, let's say this is in my root web directory:

.htaccess
index.php
myframework/

我怎么摆在那的.htaccess文件中,这样每当有人浏览的目录或文件的 myframework / ,他们会得到一个403禁止的。

What do I put in that .htaccess file so that whenever anyone browses a directory or file in myframework/ they will get a 403 forbidden.

现在,所有我做的是选项全部-Indexes 但这只prevents目录浏览 - 如果他们知道内部的确切文件网址 myframework / 那么他们就仍然可以浏览到该文件。

Right now all I am doing is Options All -Indexes but this only prevents directory browsing - if they know an exact file URL inside myframework/ then they would still be able to browse to the file.

推荐答案

有这code在DOCUMENT_ROOT .htaccess文件

Have this code in your DOCUMENT_ROOT .htaccess file

Options +FollowSymlinks -MultiViews

RewriteEngine On
RewriteRule ^myframework/ - [NC,F,L]

  • 在NC​​ - 忽略大小写比较
  • F - 马克目前的URI禁止
  • L - 马克本规则的最后一个
  • 这篇关于的.htaccess:prevent访问文件和prevent目录浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆