<p>当我们访问某个网站时,在后面增加相应的目录,就可以浏览到目录,对于网站来说,是很不安全的。</p><p> </p><p> 解决办法:</p><p> 1、编辑httpd.conf文件</p><p> vi ./conf/httpd.conf</p><p> 找到如下内容:</p><pre class="brush:bash;toolbar:false">&lt;Directory&quot;C:/ProgramFiles/Apache2.2/htdocs&quot;&gt; # #PossiblevaluesfortheOptionsdirectiveare&quot;None&quot;,&quot;All&quot;, #oranycombinationof: IndexesIncludesFollowSymLinksSymLinksifOwnerMatchExecCGIMultiViews # #Notethat&quot;MultiViews&quot;mustbenamed*explicitly*---&quot;OptionsAll&quot; #doesn&#39;tgiveittoyou. # #TheOptionsdirectiveisbothcomplicatedandimportant.Pleasesee #http://httpd.apache.org/docs/2.2/mod/core.html#options #formoreinformation. # OptionsIndexesFollowSymLinks # #AllowOverridecontrolswhatdirectivesmaybeplacedin.htaccessfiles. #Itcanbe&quot;All&quot;,&quot;None&quot;,oranycombinationofthekeywords: #OptionsFileInfoAuthConfigLimit # AllowOverrideNone # #Controlswhocangetstufffromthisserver. # Orderallow,deny Allowfromall &lt;/Directory&gt;</pre><p> 在Options Indexes FollowSymLinks在Indexes前面加上 - 符号。</p><p> 即: Options -Indexes FollowSymLinks</p><p> 【备注:在Indexes前,加 + 代表允许目录浏览;加 - 代表禁止目录浏览。】</p><p> 这样的话就属于整个Apache禁止目录浏览了。</p><p> 如果是在虚拟主机中,只要增加如下信息就行:</p><p>注意:虚拟主机中,在上面的 Options Indexes FollowSymLinks 注释掉,虚拟主机才起作用。</p><pre class="brush:bash;toolbar:false">&lt;Directory&quot;D:\test&quot;&gt; Options-IndexesFollowSymLinks AllowOverrideNone Orderdeny,allow Allowfromall &lt;/Directory&gt;</pre><p> 这样的话就禁止在test工程下进行目录浏览。</p><p>备注: 切记莫把&quot;Allow from all&quot;改成 &quot;Deny from all&quot;,否则,整个网站都不能被打开。</p><p>http://morgan363.javaeye.com/blog/645363</p><p>请问Apache如何屏蔽目录列表同时保留目录访问的默认页面?</p><p>关键字: php</p><p>在Apache的配置文件httpd.conf中找到需要设置目录的Directory属性,并在Options一行去掉Indexes </p><p> 比如说: </p><pre class="brush:bash;toolbar:false">&lt;Directory&quot;d:\web&quot;&gt; OptionsIndexesFollowSymLinks &lt;/Directory&gt; 改为: &lt;Directory&quot;d:\web&quot;&gt; OptionsFollowSymLinks &lt;/Directory&gt; ----------------------------------------------------------------- Alias/edit/&quot;/home/dbphp/db/&quot; &lt;Directory&quot;/home/dbphp/db&quot;&gt; OptionsIndexesMultiViews=&gt;OptionsMultiViews AllowOverrideNone Orderallow,deny Allowfromall &lt;/Directory&gt;</pre><p> 把Indexes去掉后,就不允许列表了。</p>
T:0.007317s,M:247.02 KB
返回顶部 留言