I want to prevent all file access and directory browsing for a directory without putting a .htaccess file in said directory.
我想要防止目录的所有文件访问和目录浏览,而不将.htaccess文件放在该目录中。
For example, let's say this is in my root web directory:
例如,假设这是在我的根web目录中:
.htaccess index.php myframework/
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.
我在。htaccess文件中放了什么,这样当任何人浏览myframework中的目录或文件时,他们就会被禁止使用403。
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.
现在我所做的是所有的- index选项,但是这只会阻止目录浏览——如果他们知道myframework/中的一个确切的文件URL,那么他们仍然可以浏览到文件。
2 个解决方案
#1
3
Have this code in your DOCUMENT_ROOT .htaccess file
在DOCUMENT_ROOT .htaccess文件中有这些代码吗
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteRule ^myframework/ - [NC,F,L]
- NC - Ignore Case comparison
- 忽略案例比较。
- F - Mark current URI Forbidden
- 禁止F标记当前URI
- L - Mark this rule as last
- 把这条规则标记为最后一条
#2
0
Enable mod_rewrite with
支持mod_rewrite与
$ sudo a2enmod rewrite
Append this to your .htaccess;
将此附加到.htaccess;
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^myframework/ - [F,L]
</IfModule>
#1
3
Have this code in your DOCUMENT_ROOT .htaccess file
在DOCUMENT_ROOT .htaccess文件中有这些代码吗
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteRule ^myframework/ - [NC,F,L]
- NC - Ignore Case comparison
- 忽略案例比较。
- F - Mark current URI Forbidden
- 禁止F标记当前URI
- L - Mark this rule as last
- 把这条规则标记为最后一条
#2
0
Enable mod_rewrite with
支持mod_rewrite与
$ sudo a2enmod rewrite
Append this to your .htaccess;
将此附加到.htaccess;
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^myframework/ - [F,L]
</IfModule>