htaccess - 可以阻止目录视图,但文件仍然可以直接查看

时间:2012-07-06 12:59:54

标签: php .htaccess

  

可能重复:
  Hotlinking my Cascading Style Sheets

这是对这个问题.htaccess don't allow user to view my folder files that don't have index.php的一个跟进,它完美地阻止了目录级访问,但是如果有人知道该URL,它仍然不会阻止直接访问

即。 domain.com/css/是禁止的,但domain.com/css/main.css显示了css文件

我将如何阻止直接访问该文件?它似乎是一个标准的东西,但我找不到它的任何东西

2 个答案:

答案 0 :(得分:4)

您可以设置如下限制:

Order Deny, Allow
Deny from all #everyone will not be allowed except the following line
Allow from 127.0.0.1 123.123.123.123 #allowed hosts separated by space

答案 1 :(得分:0)

在目录的.htaccess中,您可以写:

Deny from All

这样,任何人都无法远程访问目录中的任何内容。