国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Apache > 正文

Apache配置禁止訪問目錄403

2024-08-27 18:22:32
字體:
來源:轉載
供稿:網友

在PHP網站開發中,為了讓網站目錄文件和程序代碼的安全考慮,我們必須對某些目錄或者文件的訪問權限進行控制,來提高網站的安全,那么我們怎樣來實現這種功能呢?這時候可以配置Apache來禁止網站以目錄的形式列出網站內容.

在Apache中沒有配置禁止目錄訪問時候,當你訪問 http://localhost時會列出相關的目錄和文件列表,我們可以通過修改Apache配置文件httpd.conf來實現禁止列出目錄/文件列表,方法如下.

1、打開apache的配置文件“httpd.conf”

2、找到以下部分:

  1. <Directory /> 
  2.  
  3. Options Indexes 
  4.  
  5. AllowOverride None 
  6.  
  7. Order allow,deny 
  8.  
  9. Allow from all 
  10.  
  11. </Directory> 

只需將Options Indexes修改為Options None即可.

注:根據PHP運行環境安裝包的不同,Options Indexes也有可能是Options Indexes FollowSymLinks,一并改為Options None即可,保存httpd.conf,重啟apache,如果此時不行,繼續修改下面的配置:

  1. <Directory "E:/web"
  2.  
  3.     # 
  4.  
  5.     # Possible values for the Options directive are "None""All"
  6.  
  7.     # or any combination of: 
  8.  
  9.     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 
  10.  
  11.     # 
  12.  
  13.     # Note that "MultiViews" must be named *explicitly* --- "Options All" 
  14.  
  15.     # doesn't give it to you. 
  16.  
  17.     # 
  18.  
  19.     # The Options directive is both complicated and important.  Please see 
  20.  
  21.     # http://httpd.apache.org/docs/2.2/mod/core.html#options 
  22.  
  23.     # for more information. 
  24.  
  25.     # 
  26.  
  27.     Options none 
  28.  
  29.     # 
  30.  
  31.     # AllowOverride controls what directives may be placed in .htaccess files. 
  32.  
  33.     # It can be "All""None"or any combination of the keywords: 
  34.  
  35.     #   Options FileInfo AuthConfig Limit 
  36.  
  37.     # 
  38.  
  39.     AllowOverride None 
  40.  
  41.     # 
  42.  
  43.     # Controls who can get stuff from this server. 
  44.  
  45.     # 
  46.  
  47.     Order allow,deny 
  48.  
  49.     Allow from all 
  50.  
  51. </Directory> 
  52. //開源代碼Vevb.com 

如上:將里面紅色的部分,一并改過來就行了.

3、保存httpd.conf,并重啟Apache即可,此時再訪問 http://localhost時,如果沒有index.html或者index.php這些默認的文件時,就會報apache http 403 禁止訪問錯誤信息.

Forbidden You don’t have permission to access / on this server.

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临澧县| 梧州市| 醴陵市| 吉木乃县| 抚顺市| 田阳县| 奉节县| 芜湖县| 安化县| 宣恩县| 遂溪县| 民勤县| 兴文县| 高要市| 开原市| 普兰县| 汕尾市| 玉龙| 常熟市| 平谷区| 乐昌市| 颍上县| 宜章县| 香格里拉县| 弥勒县| 鹤山市| 金阳县| 晋城| 全椒县| 柳林县| 浦江县| 瑞金市| 阿拉善左旗| 新安县| 厦门市| 西畴县| 唐海县| 柘城县| 兴宁市| 广昌县| 扬州市|