我正在尝试限制对root中目录的访问,以便其他人无法直接在浏览器中访问这些目录中的文件。我遇到的问题现在是root中的页面,例如index.php要求输入密码,而.htaccess位于目录的根目录中,而不是域的根目录。这会阻止索引文件访问这些目录中的包含文件。
从浏览器访问锁定这些目录的简单方法是什么,同时仍然允许根目录中的文件访问它们,并且访问者可以访问根页面而不需要输入密码。我想知道他们的网站是可见的,但是,如果有人开始在子目录中窥探窃取代码,它将拒绝它们但是,允许页面访问它们。
我已经厌倦了这个我想要限制直接浏览器访问的每个目录。
<link href="https://www.anitube-nocookie.ch/res/global.css" rel="stylesheet"/>
<div id="useruploads">
<div id="pageindicator_top" class="pageindicator">
<a id="imagehost_pagebutton_1" class="buttons_medium ui-state-active" >1</a> <a id="imagehost_pagebutton_2" class="buttons_medium ui-state-active" >2</a> <a id="imagehost_pagebutton_3" class="buttons_medium ui-state-active" >3</a> <a id="imagehost_pagebutton_4" class="buttons_medium ui-state-active" >4</a> <a id="imagehost_pagebutton_5" class="buttons_medium ui-state-active" >5</a> <a id="imagehost_pagebutton_6" class="buttons_medium ui-state-active" >6</a> <a id="imagehost_pagebutton_7" class="buttons_medium ui-state-active" >7</a>
</div>
<div id="account_thumbs_clearfix">
</div>
<div id="account_thumbs">
<div id="hGhh9Oi" class="imagethumb ui-draggable ui-draggable-handle" data-pid="hGhh9Oi">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-hGhh9Oi" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="3rV4fWv" class="imagethumb ui-draggable ui-draggable-handle" data-pid="3rV4fWv">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-3rV4fWv" class="hover-icons ui-draggable ui-draggable-handle">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="CRoBsHA" class="imagethumb ui-draggable ui-draggable-handle" data-pid="CRoBsHA">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-CRoBsHA" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="ofU2T57" class="imagethumb ui-draggable ui-draggable-handle" data-pid="ofU2T57">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-ofU2T57" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="iLsZ3ON" class="imagethumb ui-draggable ui-draggable-handle" data-pid="iLsZ3ON">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-iLsZ3ON" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="EHM7Gw5" class="imagethumb ui-draggable ui-draggable-handle" data-pid="EHM7Gw5">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-EHM7Gw5" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="1SxMR9t" class="imagethumb ui-draggable ui-draggable-handle" data-pid="1SxMR9t">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-1SxMR9t" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="StxvBZi" class="imagethumb ui-draggable ui-draggable-handle" data-pid="StxvBZi">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-StxvBZi" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="5H2ndxU" class="imagethumb ui-draggable ui-draggable-handle" data-pid="5H2ndxU">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-5H2ndxU" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="OkHgAdu" class="imagethumb ui-draggable ui-draggable-handle" data-pid="OkHgAdu">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-OkHgAdu" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="Qbu49rU" class="imagethumb ui-draggable ui-draggable-handle" data-pid="Qbu49rU">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-Qbu49rU" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="O6HwQ5j" class="imagethumb ui-draggable ui-draggable-handle" data-pid="O6HwQ5j">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-O6HwQ5j" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="g1FmyqK" class="imagethumb ui-draggable ui-draggable-handle" data-pid="g1FmyqK">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-g1FmyqK" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div><div id="5WxObcv" class="imagethumb ui-draggable ui-draggable-handle" data-pid="5WxObcv">
<a class="imagethumb_element" ><img src="https://www.anitube-nocookie.ch/res/imagehost_add_album.png" /></a>
<div id="hover-icons-5WxObcv" class="hover-icons ui-draggable ui-draggable-handle" style="display: none;">
<a class="cursor-pointer " ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/link_break.png"></a> <a class="cursor-pointer" ><img class="hover-icons-subelements" src="https://www.anitube-nocookie.ch/res/cross.png"></a>
</div>
</div>
<div id="account_thumbs_clearfix"></div>
</div>
<div id="account_thumbs_clearfix">
</div>
<div id="pageindicator_bottom" class="pageindicator">
<a id="imagehost_pagebutton_1" class="buttons_medium ui-state-active" >1</a> <a id="imagehost_pagebutton_2" class="buttons_medium ui-state-active" >2</a> <a id="imagehost_pagebutton_3" class="buttons_medium ui-state-active" >3</a> <a id="imagehost_pagebutton_4" class="buttons_medium ui-state-active" >4</a> <a id="imagehost_pagebutton_5" class="buttons_medium ui-state-active" >5</a> <a id="imagehost_pagebutton_6" class="buttons_medium ui-state-active" >6</a> <a id="imagehost_pagebutton_7" class="buttons_medium ui-state-active" >7</a>
</div>
<div id="account_thumbs_clearfix">
</div>
</div>
答案 0 :(得分:1)
您需要做的就是添加以下行以及一个额外的空行来禁用索引目录:
Options -Indexes
有关详细信息,请参阅文档:http://httpd.apache.org/docs/current/mod/core.html#options
答案 1 :(得分:1)
只允许匹配php,aspx等的脚本
apache 2.2
AuthType Basic
AuthName "Administrator"
AuthUserFile /home2/mesquiu0/.htpasswds./htpasswd
Require valid-user
#Forbid access to any files except from localhost, because of Order Deny,Allow, Allow gets applied later.
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
#Allow access to files matching index.php
<Files index.php>
Order Allow,Deny
Allow from all
</Files>
在Apache 2.4中,规则已更改,正确的语法是使用Require all denied
而不是Deny from all
。
这是针对apache 2.4
AuthType Basic
AuthName "Administrator"
AuthUserFile /home2/mesquiu0/.htpasswds./htpasswd
Require valid-user
Require host 127.0.0.1
#Allow access to files matching index.php
<Files index.php>
Require all granted
</Files>
答案 2 :(得分:1)
在你的.htaccess文件中输入以下行
拒绝所有
如果您想提出例外,那就是这个。
允许所有人