Apache:返回404而不是403 / mod_access

我喜欢Order deny,allow的语法Order deny,allow方法来限制访问,我试图避免mod_rewrite:有没有一种方法,我可以让unathorized IP只是看到一个404而不是一个403,这是HTTP代码为“有顶级的秘密在这里停下来停下来“?

谢谢。

403页面依赖于Apache服务那个html ..你可以简单地通过使用ErrorDocument指令来覆盖它的任何<Location>或者<Directory>指令:

 <Directory /web/docs> ErrorDocument 403 /404-page.html </Directory> 

等.. http://httpd.apache.org/docs/1.3/mod/core.html#errordocument

请注意,这看起来像但不是一个解决scheme!

当只是提供一个自定义的错误页面(比如一个403错误的假404)时,你可能会在你的web浏览器中得到所需的结果,但是远程攻击者仍然能够从服务器获得真正的HTTP响应, 403(禁止),因此他可以猜测文件系统的结构。

在这里你可以看到curl -v -X GET http://desidered.path/forbidden_​​badly_hidden_​​folder/

 `< HTTP/1.1 403 Forbidden < Date: Thu, 04 Nov 2010 14:42:52 GMT < Server: Apache/2.2.8 (CentOS) < X-Powered-By: PHP/5.2.10 < Content-Length: 202 < Connection: close < Content-Type: text/html; charset=ISO-8859-1 < <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL was not found on this server.</p>` 

那么,我可以解决这个问题,并获得具体的每个文件夹规则deisdered输出(404找不到):

 RewriteRule ^/WebSite/forbidden_badly_hidden_folder$ /error/fake_404_403.php RewriteRule ^/WebSite/forbidden_badly_hidden_folder/$ /error/fake_404_403.php 

/error/fake_404_403.php是故意不存在的页面,那么您将从相同的curltesting中获得以下输出:

 < HTTP/1.1 404 Not Found < Date: Thu, 04 Nov 2010 14:43:12 GMT < Server: Apache/2.2.8 (CentOS) < X-Powered-By: PHP/5.2.10 < Content-Length: 202 < Connection: close < Content-Type: text/html; charset=ISO-8859-1 < <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL was not found on this server.</p>` 

这是所要求的行为;

我的问题是,是否可以编写一个全局规则,为/ var / www / html和子文件夹上的任何403(F)资源执行此类作业,将其重写为不存在的path,然后返回想要的404 Not Found?

提前致谢,并致以最诚挚的问候

马尔科